• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet mapping question

 
Greg Pola
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
This is my first posting at the ranch. But I've been lurking for a little while, and have gotten some good info from the messages posted. Thanks.

In the Servlet 2.4 Spec, chapter SRV.11 (Mapping Requests to Servlets) they have some examples of request paths and the corresponding servlet they claim will handle the request (p.87).

For a mapping of:
/foo/bar/* --> servlet1

The examples claim that requests for the following will result in servlet1 handling the request. But I dont understand why these requests would even be handled by a servlet at all. Would not the web server and/or container return the index.html or index.bop file directly? If not, what is the behavior of the servlet, and would it actually *do* anything with index.html or index.bop? Any clarifications would be appreciated.

/foo/bar/index.html
/foo/bar/index.bop

Thanks in advance,
-Greg
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet can preprocess requests in the doGet() method.
E.g. you want to display some rows of a database in a page. You requests the page by GET and the servlet gets invoked. The servlet interacts with the DAO class, obtains the list of row objects from it and puts it in the request scope. The JSP page on its turn can then access the list and display it in table.

A servlet can postprocess requests in the doPost() method.
E.g. you want to handle a login. The user submits the JSP page with the username and password entered in a POST form whose action is pointed to the servlet and the servlet gets invoked. The servlet interacts with the DAO class, obtains the User object of it and puts it in the session scope.
[ December 17, 2008: Message edited by: Bauke Scholtz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic