How to set JSP path

I am using Intellij 5.1 to develop a JSP application on a Linux machine using Tomcat. My question is:
how can i include my classes in classpath so that my .jsp can intantiate and thus use.

what i want to do is:

DBConn db = new DBConn();

where DBConn is a class i created and want to use in my jsp.

I tried to copy my class in WEB-INF/lib in my IdeaProjects folder and added this path in :
- edit configurations
- deployment
- webapp
- configure
- Libraries(classpath)

but still is giving me an http status 500 error when loading my web page.

7 comments
Comment actions Permalink

The correct location for classes is in WEB-INF/classes, WEB-INF/lib is for library jars.

0
Comment actions Permalink

when i compile my java class, IntelliJ puts my binary class (.class) into the folder:

IdeaProjects/myqpp/WebApp/exploded/WEB-INF/classes automatically but still when i run my JSP application it gives me the same error.

I added this path (WEB-INF/classes') the same as before in:
- configure
- libraries/class path as before

but still DBConn type cannot be found at runtime and gives an http 500 error.

maybe shall i change or set something in:
- configure
- paths ?

0
Comment actions Permalink

WEB-INF/classes is the default class path of a web application, so there's no need to set it anywhere. But without taking a closer look at your project I can't tell you what's going wrong. If you want me to take a look at it you can send me a snapshot of the whole project directory.

0
Comment actions Permalink

Thanks for your interest. I created a small project by just pressing next and selecting a new Web application and is giving me the same problems.

if i comment the line in TestPage.jsp:
TestClass tc = new TestClass();

when i press the run button the application runs and displays a "Hello World" message, otherwise it gives me an http status 500 error.

my startup page is set to:
http://localhost:8080/TestPage.jsp

A zip copy of the project is attached, and if you need any other info, pls ask me again

0
Comment actions Permalink

forgot the attachment . . . .



Attachment(s):
TestJSP.zip
0
Comment actions Permalink

You can't reference a class in the default package from within a JSP. So to solve your problem you have to move the class you're referencing (DBConn in your case) inside a package.

Then in your JSP you have either to write

your.package.DBConn db = new your.package.DBConn();

or to add this line to the JSP:

<%@ page import="your.package.DBConn" %>

0
Comment actions Permalink

Thanks a lot - it worked.

0

Please sign in to leave a comment.