• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

accessing servlets

 
madhur jain
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
i just passed prog. cert. and i am a beginner in servlets.
my servlets are in
C:\WINDOWS\Desktop\jsdk2.1\webpages\WEB-INF\servlets
and i use
http:/localhost:8080/servlet/MYServletName
in the browser to access the servlets
but if i want to place my servlets in another dir. say dir1 in servlets directory ie in
C:\WINDOWS\Desktop\jsdk2.1\webpages\WEB-INF\servlets\dir1

the on accessing the servlet by
http:/localhost:8080/servlet/dir1/MYServletName
gives error

can someone help what should i do.
madhur
 
Bill Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to define a servlet-mapping for your servlet in the web.xml file.
 
Thomas Hubschman
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Servlet classes should all be in the following directory (as per spec.)
webContainer/webapps/myWebApp/WEB-INF/classes
If they are in a package they should be be in the appropriate directory, i.e.
webContainer/webapps/myWebApp/WEB-INF/classes/gov.fbi.SecretFileServlet
You then can map a name to the servlet like:
http://www.fbi.gov/myWebApp/SecretFileServlet
in the web.xml file (which is located in the WEB-INF directory).
Hope this helps,
Thomas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic