Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Reading init param

How do you read init parameters from web.xml and importance of ServletConfig

  • Login to see the comments

  • Be the first to like this

Reading init param

  1. 1. Reading init param By Sana mateen
  2. 2. ServletConfig interface • What is the need? • Sometimes we may have a requirement that a value keeps changing time to time and so we do not want to hard code it into a servlet. If it is done, we will have to change the value and again recompile the servlet. • How can it be achieved? • Servlet specification provides a way to provide init parameters to the servlet when it is initialized. i.e. its init() method completes. These init parameters are available in the servlet. Parameters can be accessed using public String getInitParameter(String name) method. • Advantage of ServletConfig • The core advantage of ServletConfig is that you don't need to edit the servlet file if information is modified from the web.xml file.
  3. 3. HTTP STATUS CODES • The Status-Code element in a server response, is a 3-digit integer where the first digit of the Status-Code defines the class of response and the last two digits do not have any categorization role. There are 5 values for the first digit:
  4. 4. Methods to set HTTP status code • public void setStatus ( int statusCode ) • public void sendRedirect(String url) • public void sendError(int code, String message)