NonameSL
NonameSL

Reputation: 1475

Importing own java files in jsp

I'm kind of a JSP noob (and I'm forced to write old school because of school) and I have this pure java file that I wrote. I want to use that FooBar.java file and the class inside it (packagename.name.FooBar) inside my .jsp files. My questions are:

EDIT: Now I've tried compiling them and putting them in WEB-INF/classes/packagename/name, but I still get errors:

Only a type can be imported. packagename.name.FooBar resolves to a package

And then of course these (because it didn't import correctly): FooBar cannot be resolved to a type.

What am I doing wrong?

EDIT: Thank you everyone! If you're wondering, here's what solved my problem:

Upvotes: 1

Views: 745

Answers (1)

Ori Marko
Ori Marko

Reputation: 58902

JSP file can import files with class extension and not java extension.

Class file is a compiled java file.

You need to compile you java file which will create FooBar.class

One option is to save FooBar.class file in a jar under /WEB-INF/lib

Second option is save FooBar.class inside your classes folder under relevant pack for example if your package is a.b /WEB-INF/classes/a/b/FooBar.class

Upvotes: 1

Related Questions