• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion is JSP initialization

 
Ankit Mishra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I am stuck a bit in initialization in jsp.

Below is the code from Head First JSP and Servlets(Second Edition)




now my questions are :

1. why I have used ServletConfig here when we can directly work with ServletContext to set an application scope attribute (provided i write parameters in context-param in dd).
2. Even if i am using ServletConfig to get init parameter what exactly it means . Since in servlet this means i am getting parameters for a particular servlet. But here I am setting parameters in application scope.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the DD, you do not set Servlet Context Attributes, but Parameters. Whatever you declare in the DD is final and cannot be changed afterwards. Maybe that is why a Servlet Config Parameter was chosen that is then moved to a Servlet Context Attribute. This way it is possible to change it afterwards.
 
Ankit Mishra
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Sebastian for your reply i got your point thanks and also thanks for correcting me ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic