wood burning stoves 2.0*
The moose likes Servlets and the fly likes Beginners ques- servlet not deploying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Beginners ques- servlet not deploying" Watch "Beginners ques- servlet not deploying" New topic
Author

Beginners ques- servlet not deploying

sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40
I am using Tomcat 4.1.29 and trying to deploy a servlet.
Created following directories in webapps
chapter01\WEB-INF\classes
In the classes directoy created HelloWorldServlet.java and compiled it. Created web.xml file in WEB-INF directory.


But when i try to run it in a browser using
http://localhost:8080/chapter01/HelloWorldServlet
I get the resource not available error.
Please Help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

All java classes, including servlets, should be in a package other than the default.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40
Thanks for repling.
I have created com package in classes and placed the file in it.



Do i need to make any changes to web.xml file?
I am trying to access it as
http://localhost:8080/chapter01/com/HelloWorldServlet
and still getting the same error.
sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40
Also tried the following.
In web.xml

and accessing it using
http://localhost:8080/chapter01/HelloWorldServlet
Still not working. Please Help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Add a servlet-mapping to your web.xml to assign a url pattern to the servlet.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
try this
at the end of all your <servlet> ....</servlet> tags add the following
<servlet> <servlet-name>HelloWorldServlet</servlet-name> <servlet-class>com.HelloWorldServlet</servlet-class> </servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/chapter01/*</url-pattern>
</servlet-mapping>

Cheers
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40
Did the following and now its working fine.




Thank you so much
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
whats the url you using now ?
sylvia greene
Ranch Hand

Joined: Jun 23, 2004
Posts: 40
Originally posted by Praful Thakare:
whats the url you using now ?


http://localhost:8080/chapter01/HelloWorldServlet
 
jQuery in Action, 2nd edition
 
subject: Beginners ques- servlet not deploying
 
Similar Threads
404 Error...need help
resource not available.
resource not available.
About executing servlet class
HelloWorldServlet