aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problems Running Servlet code on Win 2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problems Running Servlet code on Win 2000" Watch "Problems Running Servlet code on Win 2000" New topic
Author

Problems Running Servlet code on Win 2000

Jaggi Kunal
Ranch Hand

Joined: Jan 21, 2003
Posts: 45
I have downloaded the Apache Tomcat Software (Tomcat 4.1) and appropriately set the two environmental variables namely- JAVA_HOME and CATALINA_HOME. I am using Windows 2000 Pro. The Web server is running fine at http://localhost:8080/. The classpath is set appropriately.
I have compiles a TestServlet.java file and placed the same in in install_dir/webapps/ROOT/WEB-INF/classes directory. After compiling the code, access the servlet with the URL http://localhost/servlet/HelloServlet (or http://localhost:8080/servlet/HelloServlet but it is giving me error messag. So, what could be the problem.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Jaggi Kunal:
[...] but it is giving me error messag. So, what could be the problem.
I've pumped up my karma 'till it burst and had seances with all my astral connections, but I still cannot discern the nature of the error message by occult means. Perhaps posting the message text and, if possible, a stack trace would help?
- Peter
Jaggi Kunal
Ranch Hand

Joined: Jan 21, 2003
Posts: 45
The exact error message is given below:
type Status report
message /servlet/TestServlet
description The requested resource (/servlet/TestServlet) is not available.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Can you see static files? Is the servlet in a package, and do you use directory names reflecting the package names?
- Peter
Jaggi Kunal
Ranch Hand

Joined: Jan 21, 2003
Posts: 45
No, the servlet is not in a package.
What is a static file?
Regards,
Kunal Jaggi
SCJP2
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
hello Jaggi,
it appears you have not mentioned mapping your servlet. Try mapping it in your web.xml.
e.g. <servlet-mapping ....
Srinivas M
Greenhorn

Joined: Dec 18, 2002
Posts: 12
You need to uncomment the following code in the web.xml file under <your tomcat install folder>/conf
Look for the following lines and uncomment the lines related to the invoker servlet
<!-- The mapping for the invoker servlet -->
<!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
-->
Now restart your tomcat server and test the example using the URL
http://localhost:8080/chapter01/servlet/HelloWorldServlet
It will work for you now.
Srinivas
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
Jaggi,
You should definitely try Srinivas's suggestion (it works for me like a charm when I just come to tomcat world)
more detailed info, the section Srinivas mentioned
is around lines 273-278 inside the web.xml I have (i am using 4.1.18).
<!-- The mapping for the invoker servlet -->
<!-- remove this
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
--> remove this
[ January 31, 2003: Message edited by: chi Lin ]

not so smart guy still curious to learn new stuff every now and then
Jaggi Kunal
Ranch Hand

Joined: Jan 21, 2003
Posts: 45
Hello Srinivas,
Many thanks to u and all others. Now I can run the servlet code. Srinivas, which book are you using to prepare for SCWCD Certification? I have recently purchased the Wrox SCWCD book. After having gone through the first few chapters I can say that this book is not for beginners like me who are new to Servlets and JSP. Is there any book on Servlets/JSP which requires no prerequisites, how about Core Servlets and JSP by Marty Hall, although the Indian reprint of this book is not available, but is it worth the cost (Approx. Rs. 1029/-).
Regards,
Kunal Jaggi
SCJP2
[ January 31, 2003: Message edited by: Jaggi Kunal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems Running Servlet code on Win 2000
 
Similar Threads
deployement of a simple servlet
unable to compile
where to put servlets? (searched 1st)
how to use the servlet in tomcat??
HelloServlet not running ?