Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My servlet Notes

 
narain ashwin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have prepared the below notes covering the basic ways a servlet can get information from outside world, kindly request you to validate whether my understanding is right
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2337
87
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narain,

Just some remarks on your short summary (please check the API for the parameters and return types)
request.getParameter() - For HTML form elements(including cookies)

getting cookies is done by calling request.getCookies()
request.getAttribute() - For requests forwarded via RequestDispatcher

For objects stored in the request (those are probably set by calling request.setAttribute() before calling the RequestDispatcher)

ServletConfig.getInitParameter() - For paramers defined using <init-param> in DD

Be careful here, this are the init parameters for the Servlet defined inside the <servlet> element, you also have init parameters for the whole web-application (ServletContext) defined in the <context-param> element of the DD
ServletContext.getAttribute() - For Objects stored in ServletContext(Shared b/w mutiple request for same servlet)

These objects are shared through the whole web-application, so for all the servlets defined in de DD!

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic