Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I access a class through jsp?? 1

Status
Not open for further replies.

FreshmenProgrammer

Programmer
Jan 16, 2006
42
CA
I have my connection code in my .jsp file but i wand to put it in its own class or .jsp. What does anyone recommend is there anyway I can right a class for that and Create an instance of the class in a jsp and use it.
 
Yes.

In your Java, you should have something like this:
Code:
package exampleClasses;

public class MyClass{

}

Compile the above and make sure it is in WEB-INF/classes/exampleClasses

In the JSP:

Code:
<%@ page import="exampleClasses.MyClass" %>

The import things to note: the inclusion of a package in the Java code, the directory, with that package name, under WEB-INF/classes/, and, of course, the import statement in your JSP.

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top