Reading init param
By
Sana mateen
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.
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:
Methods to set HTTP status code
• public void setStatus ( int statusCode )
• public void sendRedirect(String url)
• public void sendError(int code, String
message)
Reading init param
Reading init param
Reading init param
Reading init param

Reading init param

  • 1.
  • 2.
    ServletConfig interface • Whatis 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.
  • 8.
    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:
  • 11.
    Methods to setHTTP status code • public void setStatus ( int statusCode ) • public void sendRedirect(String url) • public void sendError(int code, String message)