Java Servlets Question and Answers

5. What are different implicit objects of JSP?
 
  • pageContext: The pageContext object.
  • pageScope: A Map of all the objects that have page scope.
  • requestScope: A Map of all the objects that have request scope.
  • sessionScope: A Map of all the objects that have session scope.
  • applicationScope: A Map of all the objects that have application scope.
  • param: A Map of all the form parameters that were passed to your JSP page.
  • paramValues: HTML allows for multiple values for a single form parameter. This is a Map of all the parameters, just like param, but in this object the values are an array containing all of the values for a given parameter in the event that there's more than one.
  • header: A Map of all the request headers.
  • headerValues: For the same reasons as paramValues, a headerValues object is provided.
  • cookie: A Map of all the cookies passed to your JSP. The value returned is a Cookie object.
  • initParam: A Map that maps context initialization parameter names to their parameter values.
 
Your Name Your Email-ID
Your Answer
6. What are the two important API's in for Servlets?
 
  • Two important packages are required to build servlet "javax.servlet" and javax.servlet.http.
  • They form the core of Servlet API. Servlets are not part of core Java but are standard extension provided by Tomcat.
 
Your Name Your Email-ID
Your Answer
7. What are different Authentication options available in servlets?
  There are four ways of authentication
  • HTTP basic authentication: In HTTP basic authentication the server uses the username and password send by the client. The password is sent using simple base64 encoding but it's not encrypted.
  • HTTP digest authentication: HTTP digest authentication is same as HTTP basic authentication but the biggest difference is password is encrypted and transmitted using SHA or MD5.
  • HTTPS client authentication: HTTPS client authentication is based on HTTP over SSL. It requires that the end client should posses a PKC (Public Key Certificate). This verifies the browsers identity.
  • Form based authentication: In Form based the web container invokes a login page. The invoked login page is used to collect username and password.
 
Your Name Your Email-ID
Your Answer
8. Which are the different ways you can communicate between servlets?
  Below are the different ways of communicating between servlets:-
  • Using RequestDispatcher object.
  • Sharing resource using "ServletContext()" object.
  • Including response of the resource in the response of the servlet.
  • Servlet chaining.
 
Your Name Your Email-ID
Your Answer
1234567891011 Page 2 of 11