• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

HELP! JAVA programer expertise needed....

halik

Lifer
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???
 
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.
 
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.
 
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
 
Is that class part of a package? Try adding this to the top of jsp file:

<%@ page import="your.package.name.*"%>
 
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;
}

}
 
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"
 
Back
Top