Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error running servlet using tomcat.. help please

 
anuja parikh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Bhoot Sahai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic