• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems Running Servlet code on Win 2000

 
Jaggi Kunal
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the servlet is not in a package.
What is a static file?
Regards,
Kunal Jaggi
SCJP2
 
boyet silverio
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jaggi Kunal
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic