• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beginners ques- servlet not deploying

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a servlet-mapping to your web.xml to assign a url pattern to the servlet.
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did the following and now its working fine.




Thank you so much
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whats the url you using now ?
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Praful Thakare:
whats the url you using now ?



http://localhost:8080/chapter01/HelloWorldServlet
 
Beauty is in the eye of the tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic