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!

Problem importing my own class

Status
Not open for further replies.

Gaelle

Programmer
Jun 20, 2001
62
FR
hi !

I have a class (simulateur.class/.java) I need to make an instance of in my JSP page.
From things I've read, I understood that my class ought to be in a package. So I created a directory (simul) where my JSP pages are and put and compiled my Java class in it.
Now I can't have my JSP page working :
I tried to import like this :
<%@ page import = &quot;simul.simulateur&quot; %>, but then I get the message : Class simul.simulateur not found in import
then <%@ page import = &quot;simul.*&quot; %> gives me : Package simul not found in import
And so on...
So, how does the correct call look like ?

Thanks,
Gaelle.
 
You need to set a class path for your owner classes so that tomcat knows where to find them. This can be done by editing the tomcat.bat file, which can be found at

&quot;your tomcat dir&quot;/bin/tomcat.bat

just add in somthing like the following

set CP=%CP%;%TOMCAT_HOME%\webapps\Simulater\classess

and place all of your classes within this folder.

Hope this helps
Daniel
 
Thanks for helping me !

But do I need to create a web application or something, or place the class I want to call in a special directory ?
I have placed my JSP files under :
c:\Tomcat4.0\webapps\Root\myappli\, and access them by .
So where should I place my class (Simulateur.class) ?

Gaëlle.
 
you can place them where ever you wish as long as you set the class path.
I like to place them in a directory coming off of the root of my application. So using your example i would put my classes in the directory

c:\Tomcat4.0\webapps\Root\myappli\bin\
 
Yes !!!

At least, it works !
It was indeed a classpath failure : I have set it in both catalina.bat and setclasspath.bat and it seems to work !

Let's hope it will last now !
Thanks over again !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top