Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Error running servlet using tomcat.. help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Error running servlet using tomcat.. help please" Watch "Error running servlet using tomcat.. help please" New topic
Author

Error running servlet using tomcat.. help please

anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
Dear friends
I m trying to compile and run the servlet since last few hours but in vain... i did set my classpath in autoexec.bat file as follows..
set JAVA_HOME=c:\jdk1.3
set TOMCAT_HOME=c:\tomcat
path=c:\tomcat\bin;
path=c:\jdk1.3;
set classpath=c:\jdk1.3\jre\lib\rt.jar;
set classpath=c:\tomcat\common\lib\servlet.jar;c:\jdk1.3\src.jar;c:\jdk1.3\lib\tools.jar;
i m able to compile my servlet TestServlet and both java and class files r stored in tomcat\webapps\examples\web=inf\classes
directory...
but now when i start to run tomcat in c:\tomcat\bin\startup.bat
i get the following error message :
Using CLASSPATH: ..\bin\bootstrap.jar;c:\jdk1.3\lib\tools.jar
Bad Command or file name
can to help u to solve this problem and run my servlet in browser...
thanks
anu


Jayson Falkner
Author
Ranch Hand

Joined: May 07, 2001
Posts: 57
Servlets don't run in web browsers. Servlets live in your web server(IE: Tomcat) and are configured via the web.xml file.
To solve resource issues with your classpath do this. Take your servlet.jar resource out of the classpath entirely. Instead place it in the TOMCAT_HOME/lib directory. This will have the same effect and cause less headaches. You can do this with any new resources, try it out.
Next add the needed blurbs in your web.xml file. For a better example look at the examples provided with your Tomcat distribution. A ficticious example for the 'snoop' servlet would look like this:

One entry to manage the new servlet. One entry to map URL's to the servlet.
Jayson Falkner
V.P./CTO, Amberjack Software LLC
Jayson@jspinsider.com
www.jspinsider.com
[This message has been edited by Jayson Falkner (edited May 08, 2001).]


Jayson Falkner<br />jayson@jspinsider.com<br />Author of <a href="http://www.jspbook.com" target="_blank" rel="nofollow">Servlets and JavaServer Pages; the J2EE Web Tier</a>
Bhoot Sahai
Greenhorn

Joined: May 05, 2001
Posts: 6
Also, change:
path=c:\tomcat\bin;
path=c:\jdk1.3;
set classpath=c:\jdk1.3\jre\lib\rt.jar;
set classpath=c:\tomcat\common\lib\servlet.jar;c:\jdk1.3\src.jar;c:\jdk1.3\lib\tools.jar;
to:
path=c:\tomcat\bin;
path=%path%;c:\jdk1.3;
set classpath=c:\jdk1.3\jre\lib\rt.jar;
set classpath=%classpath%;c:\tomcat\common\lib\servlet.jar;c:\jdk1.3\src.jar;c:\jdk1.3\lib\tools.jar;

B Sahai
anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
hello friends...
thanks for ur replies but still i m getting the same error message when i try to start server using startup.bat
anu
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
Please see
http://www.javaranch.com/ubb/Forum7/HTML/003345.html and http://www.javaranch.com/ubb/Forum7/HTML/003348.html
Then if it still doesnt work, post back here
anuja parikh
Greenhorn

Joined: May 07, 2001
Posts: 6
thanks Mak...for ur help..
actually i was trying the same thing and had already referred this earlier before writing over here...but that i couldnt do...but when tried today i could succeed...i couldnt understand what i was doing wrong there...anyways once again thanks...and one more thing is it necessary in servlets to save all java and class files in ur classes directory...is that so what is the reason???
anu
Jayson Falkner
Author
Ranch Hand

Joined: May 07, 2001
Posts: 57
Yes, you need to give your JSP container access to all the class files you are using. If you make a custom servlet, then the container needs to know about it before using.
One way to do this is by saving all of your class files in the WEB-INF/classes directory under the correct package(or no package if you are not using one). Another way is to make a JAR that contains your resources and place this in your WEB-INF/lib directory.
The most commonly suggested way is to edit your classpath or path to include the resources. This method tends to cause trouble much like you had previously.
The important thing is that the container can access your resources somehow. Without them it cannot create your JSP or find the right class to use as a servlet.
Jayson Falkner
V.P./CTO, Amberjack Software LLC
Jayson@jspinsider.com
www.jspinsider.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error running servlet using tomcat.. help please