15
Reading init param By Sana mateen

Reading init param

Embed Size (px)

Citation preview

Page 1: Reading init param

Reading init param

BySana mateen

Page 2: Reading init param

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.

Page 3: Reading init param
Page 4: Reading init param
Page 5: Reading init param
Page 6: Reading init param
Page 7: Reading init param
Page 8: Reading init param

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:

Page 9: Reading init param
Page 10: Reading init param
Page 11: Reading init param

Methods to set HTTP status code

• public void setStatus ( int statusCode )• public void sendRedirect(String url)• public void sendError(int code, String

message)

Page 12: Reading init param
Page 13: Reading init param
Page 14: Reading init param
Page 15: Reading init param