Java Servlets and JSP Programming

Tests knowledge of Java Servlets, JSP, and related web technologies including servlet lifecycle, configuration, listeners, session management, and HTTP handling. Useful for Java EE certification and web development exams.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is a correct statement about the getParameterValues method?

  1. This method accepts only a single argument.
  2. This method can accept multiple arguments.
  3. It returns the an array of integers containing all the values for the parameter.
  4. It provides thread-safety to the applications.
  5. This method is used to set the bean's values.
Question 2 Multiple Choice (Single Answer)

Which of the following statements is not applicable for the SingleThreadModel in the servlet applications?

  1. This is an interface implemented by the servlet.
  2. This is an abstract class which extends the servlet interface.
  3. The SingleThreadModel ensures that the servlet will handle one request at a time.
  4. The SingleThreadModel does not have any method.
  5. None of these
Question 3 Multiple Choice (Single Answer)

Which of the following statements is/are not applicable for the ServletConfig and ServletContext objects?

  1. ServletConfig interface is used to pass the information from the servlet container to the servlet during the servlet initialisation.
  2. The getInitParameter() method returns null if the parameter does not exist.
  3. ServletContext object is an interface between the servlet container and a servlet.
  4. The only ServletContext object should be in a web application.
  5. None of these
Question 4 Multiple Choice (Single Answer)

Which of the following statements is not applicable for the GenericServlet class in the servlet applications?

  1. This is an abstract class which extends the servlet interface.
  2. It provides protocol independent servlet.
  3. This class has getServletInfo(), getServletName() and getInitParameterNames() methods.
  4. This class has getServletInfo(), getServletName() and getValue() methods.
  5. GenericServlet class implements servlet, ServletConfig and serialisable interfaces.
Question 5 Multiple Choice (Single Answer)

Which of the following statements is not applicable for the exceptions in the servlet applications?

  1. The javax.Servlet package defines the various exceptions.
  2. A ServletException is known as the generic exception.
  3. The getRootCause method returns the cause of ServletException.
  4. The UnavaiableException determines that the servlet or filter is not available.
  5. The javax.servlet.error.exception gives information about exception type which can be stored and analysed after storing in a java.lang.Class data type.
Question 6 Multiple Choice (Single Answer)

Which of the following statements is/are correct about JspFactory method in the javax.servlet.jsp package?

  1. It is an abstract class which provides the number of methods to obtain the various runtime objects of the JSP page.
  2. The instance of JspFactory container class is created by the JSP container.
  3. It is an implicit object.
  4. All of the above
  5. Only (1) and (2)
Question 7 Multiple Choice (Single Answer)

Which of the following is an incorrect statement about servlet programming?

  1. SC_FORBIDDEN method produces predefined error messages like HTTP error 403.
  2. We can send a custom error message for the error message in SC_FORBIDDEN method.
  3. HttpServletResponse allows to send the error message in the servlet code.
  4. HtttpServletResponse interface provides protocol specific methods.
  5. There can be many objects of a servlet created for a request.
Question 8 Multiple Choice (Single Answer)

Which of the following methods is used to clear the buffer content, status code and headers?

  1. public void resetBuffer()
  2. public void rest()
  3. public void getBuffer()
  4. public void setBufferSize()
  5. None of these
Question 9 Multiple Choice (Single Answer)

What is the significance of HttpSessionAttributeListener interface?

  1. The class implementing this interface determines the notification about the sessions.
  2. The class implementing this interface determines the notification of changes to the HttpSession object's attribute.
  3. This interface defines a session specific to the user requesting the servlet.
  4. Both (1) and (2)
  5. None of these
Question 10 Multiple Choice (Single Answer)

Which of the following does the ServletContextListener class provide in the servlet application?

  1. This class provides notifications in the ServletContext object.
  2. The contextDestroyed() method determines whether the servlet container is shut down.
  3. The contextInitialized() method determines that the web application is ready to service the request.
  4. All of the above
  5. Only (1) and (3)
Question 11 Multiple Choice (Single Answer)

Which of the following statements is true about buffering the response in servlet application?

  1. Buffering is used to enhance the performance of the servlet.
  2. We can change the default buffer size.
  3. The default buffer size is 8.192 characters.
  4. The output of the browser cannot be sent until the servlet process is finished or the buffer is full.
  5. All of the above
Question 12 Multiple Choice (Single Answer)

Which of the following methods is/are used to return the preferred locale for the content that the client will accept?

  1. public java.util.Enumeration getLocales()
  2. public java.util.Locale getLocale()
  3. Both (1) and (2)
  4. public java.util.Locales getLocale()
  5. None of these
Question 13 Multiple Choice (Single Answer)

What is the role of HTTP (Hyper Text Transfer Protocol) for the web servers?

  1. HTTP protocol exchanges the data over the web.
  2. The connection is established by the client in HTTP.
  3. The client and server both are responsible to terminate the connection.
  4. All of the above
  5. Only (1) and (2)
Question 14 Multiple Choice (Single Answer)

Which of the following conditions is/are not applicable for the init() method in servlet life cycle?

  1. The init() method can be called only once.
  2. The init() method can be overriden.
  3. The init() method can not throw any exception.
  4. The destroy() method ensures that the persistent state is synchronised.
  5. None of these
Question 15 Multiple Choice (Single Answer)

What is the significance of HttpSessionActivateListener interface in servlet application package?

  1. The class implementing this interface determines the notification about the sessions.
  2. The class implementing this interface determines the notification of changes to the HttpSession object's attribute.
  3. This interface defines a session specific to the user requesting the servlet.
  4. Both (1) and (2)
  5. None of these