Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

servlet mapping question

 
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
 
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 ]
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic