Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginners ques- servlet not deploying

 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64845
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All java classes, including servlets, should be in a package other than the default.
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64845
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a servlet-mapping to your web.xml to assign a url pattern to the servlet.
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the following and now its working fine.




Thank you so much
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whats the url you using now ?
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Praful Thakare:
whats the url you using now ?


http://localhost:8080/chapter01/HelloWorldServlet
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic