reading init param
TRANSCRIPT
![Page 1: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/1.jpg)
Reading init param
BySana mateen
![Page 2: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/2.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/3.jpg)
![Page 4: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/4.jpg)
![Page 5: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/5.jpg)
![Page 6: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/6.jpg)
![Page 7: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/7.jpg)
![Page 8: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/8.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/9.jpg)
![Page 10: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/10.jpg)
![Page 11: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/11.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/12.jpg)
![Page 13: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/13.jpg)
![Page 14: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/14.jpg)
![Page 15: Reading init param](https://reader035.vdocument.in/reader035/viewer/2022062900/58ceb5451a28abb2218b59bb/html5/thumbnails/15.jpg)