HELP! JAVA programer expertise needed....

halik

Lifer
Oct 10, 2000
25,696
1
81
Im having problems with one of my jsps.
I made this data container classes that i wanna pass between the servlet and jsp. The classes resides in the same directory the servlet does (WEB-INF/classes/), but the jsp sits in the root directory of the webserver. I cant get the JSP to find the contrainer classs at all.... where should i put it or is it a classpath problem or something???
 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
It would be the classpath. It depends on your web server how you have to handle things. I haven't done this myself, but we have done some JSP stuff here at work and I know some time was spent on figuring how to register classes with the web server.
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
What app server are you using? Did you import appropriate packages from the jsp? Either WEB-INF/classes or WEB-INF/lib (if class files are contained in a *.jar file) should be sufficient.
 

halik

Lifer
Oct 10, 2000
25,696
1
81
Originally posted by: Argo
What app server are you using? Did you import appropriate packages from the jsp? Either WEB-INF/classes or WEB-INF/lib (if class files are contained in a *.jar file) should be sufficient.

im using tomcat
I dont know how to import the class from within the jsp... i figured it would know whats up as the servlet has the class.

The class itself sits in /WEB-INF/classes/ - the same place the servlet resides. whereas the JSP is just in /
Like i said the servlets find the class just fine, but jsp cant find it. I tried softlinking it from /WEB-INF/classes to /WEB-INF/lib but that didnt help either
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
Is that class part of a package? Try adding this to the top of jsp file:

<%@ page import="your.package.name.*"%>
 

halik

Lifer
Oct 10, 2000
25,696
1
81
nope it just single class

public class contentData {

private String title;
private String text;
private String link;
/** Creates a new instance of contentData */

public contentData(String title, String text, String link)
{
this.title = title;
this.text = text;
this.link = link;
}

}
 

halik

Lifer
Oct 10, 2000
25,696
1
81
figured it out

the class i wanna import needs to have some kinda of packagename

package myrandomname;

and then you put it into WEB-INF/classes/myrandomname

from the servlet you do import myrandomname.nameoftheclass

and from the jsp you do
@ page import = "myrandomname.nameoftheclass"