Java Servlets and Web Development

Questions about Java Servlets, HTTP methods, session management, and web application configuration

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

what is class available for http process in servlet

  1. GenericServlet
  2. service()
  3. doTrace()
  4. HttpServlet class its a sub class of GenericServlet class
Question 2 Multiple Choice (Single Answer)

difference between Servlet and CGI

  1. no difference
  2. servlet runs slowly than CGI
  3. CGI is a complex process , servlet is easier ie lieght weight component
  4. none of these
Question 3 Multiple Choice (Single Answer)

what are all the methods available in HttpServlet class

  1. service() only
  2. destroy()
  3. doPost,doGet
  4. doPost,doGet,doTrace(),doOption(),doDelete()
Question 4 Multiple Choice (Single Answer)

Difference between doPost() and doGet()

  1. data size is limited(upto 256 datas) in doGet() , doPost has no limit for datas
  2. doPost() is secure than doGet
  3. both of above
  4. none of these
Question 5 True/False

Can we run serlvet class without web.xml file in server

  1. True
  2. False
Question 6 Multiple Choice (Single Answer)

Difference between serveltContext and servletConfig interface

  1. both are same
  2. servletConfig helps for share information to all serlvet classes
  3. servletCofig for particular servlet configuration and servletContext toshare information to all serlvet classes
  4. none of these
Question 7 Multiple Choice (Single Answer)

What is a use of RequestDispatcher interface

  1. for forward the request
  2. for include the content from the another URL
  3. both of these
  4. only for forward the request
Question 8 Multiple Choice (Single Answer)

Which tag used for security of appliction in web.xml

  1. <servlet-class>
  2. <taglib-url>
  3. <security-constraint>
  4. <init-param>
Question 9 Multiple Choice (Single Answer)

What details in MANIFEST.MF file

  1. contains which jar file will executed
  2. deployment descriptor file
  3. emty file for future use of servlet
  4. none of these
Question 10 Multiple Choice (Single Answer)

How to maintain session in servlet

  1. http session
  2. cookies
  3. URL rewriting, hiddenform fields
  4. httpsession,hiddenform fields,rewriting,cookies
Question 11 Multiple Choice (Single Answer)

Which type is preferable to maintain session

  1. cookies because user can turn off it
  2. hidden form field because of its performance is moderate
  3. httpsession because no limit for session data and performance is good
  4. Url rewriting becasue its easy
Question 12 Multiple Choice (Single Answer)

Is it possible to servlet have a constructor

  1. yes but then serlvet will not work properly ie can't provide initilization parameters
  2. not possible
  3. sometimes only
  4. none of these
Question 13 Multiple Choice (Single Answer)

Difference between GenericServlet and Httpservlet class

  1. GenericServlet normal purpose HttpSerlvet for complex process
  2. both are same but parameters are different
  3. both of above
  4. GenericServlet is protocol independent, HttpServlet is protocol dependent
Question 14 Multiple Choice (Single Answer)

differnce between sendRedirect() and forward()

  1. sendRedirect for redirect request on server side forward process
  2. SendRedirect on client side process and forward on browser side process
  3. sendRedirect for slow and forward for fast
  4. none of these
Question 15 Multiple Choice (Single Answer)

different between getRequestDispatcher() javax.servlet.servletRequest and javax.servlet.servletContext

  1. javax.servlet.servletRequest accepts relative path and javax.servlet.servletContext doesn't accepts relative path
  2. both are same
  3. javax.servlet.servletRequest for include and javax.servlet.servletContext for forward
  4. all of above