• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error running servlet using tomcat.. help please

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Author
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic