General discussion

Locked

CLASSPATH

By ururya ·
hOW DO I set up the classpath to handle servlets. How do I put servlet.jar in the classpath. I'm using Tomcat-Jakarta3.3a & jdk1.3.1

when I try to run my servlet in the jdk directory, I get an error. Servlet cannot be read

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

CLASSPATH

by okujava In reply to CLASSPATH

a) To install servlets within a web-application, you can do the following:

* Once a servlet has been compiled, it can be added to Tomcat by:
determine which "web application" context you'd like to add the servlet
to

add the servlet class file to the
WEBAPP/WEB-INF/classes directory

* In order to define a name and init params for the newly installed
servlet you need to also:

register the servlet with a <servlet> element in the
WEBAPP/WEB-INF/web.xml file

you can optionally map your servlet
to uri requests relative to the context
within it is located by adding a <servlet-mapping>
element in the WEBAPP/WEB-INF/web.xml
file
* And finally restart the server
You can access your new servlet via a URI similiar
to the following:
http://localhost:8080/WEBAPP/servlet/SERVLET-NAME

see http://jakarta.apache.org/tomcat/tomcat-3.3-doc/faq for details

cheers

Collapse -

CLASSPATH

by ururya In reply to CLASSPATH

Poster rated this answer

Collapse -

CLASSPATH

by okujava In reply to CLASSPATH

OK! let's make it step by step:
1. you have installed jdk1.3.1, right? you need the servlet.jar archive in addition to that. go to http://java.sun.com/products/servlet/download.html and download class files version 2.3. unpack them in your jdk1.3/lib directory.
2. then take your servlet-java file and copy it to tomcat/webapps/yourwebapp/WEB-INF/classes directory.
3. open the dos box and navigate to the directory, where you have copied the .java-file.
4. type javac -version. if you becomethe version number, it's ok. if not, type "set PATH=c:\jdk1.3\bin;%PATH%" without quotes (change the c:\jdk1.3 directory to your jdk install directory if needed).
5. type "set CLASSPATH=.;c:\jdk1.3\lib\servlet.jar" without quotes (change the c:\jdk1.3 directory to your jdk install directory if needed).
6. type javac *.java - your servlet should be compiled. if not, please comment my answer and tell me at which step did you become problems.
7. see the answer above...

Collapse -

CLASSPATH

by ururya In reply to CLASSPATH

The question was auto-closed by TechRepublic

Collapse -

CLASSPATH

by ritamdsharma In reply to CLASSPATH

To set the classpath go to the environment variables by right clicking the My Computer and selecting Properties option. Within which go into Advanced and enter the path where you have your j2ee.jar file. The class path is then set. Now try running your servlet file in Apache server, it should not throw you any error.
Regards,
Ritam

Collapse -

CLASSPATH

by ururya In reply to CLASSPATH

The question was auto-closed by TechRepublic

Collapse -

CLASSPATH

by ururya In reply to CLASSPATH

This question was auto closed due to inactivity

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Forums