Java Servlets and Web Development
Questions about Java Servlets, HTTP methods, session management, and web application configuration
Questions
what is class available for http process in servlet
- GenericServlet
- service()
- doTrace()
- HttpServlet class its a sub class of GenericServlet class
difference between Servlet and CGI
- no difference
- servlet runs slowly than CGI
- CGI is a complex process , servlet is easier ie lieght weight component
- none of these
what are all the methods available in HttpServlet class
- service() only
- destroy()
- doPost,doGet
- doPost,doGet,doTrace(),doOption(),doDelete()
Difference between doPost() and doGet()
- data size is limited(upto 256 datas) in doGet() , doPost has no limit for datas
- doPost() is secure than doGet
- both of above
- none of these
Can we run serlvet class without web.xml file in server
- True
- False
Difference between serveltContext and servletConfig interface
- both are same
- servletConfig helps for share information to all serlvet classes
- servletCofig for particular servlet configuration and servletContext toshare information to all serlvet classes
- none of these
What is a use of RequestDispatcher interface
- for forward the request
- for include the content from the another URL
- both of these
- only for forward the request
Which tag used for security of appliction in web.xml
- <servlet-class>
- <taglib-url>
- <security-constraint>
- <init-param>
What details in MANIFEST.MF file
- contains which jar file will executed
- deployment descriptor file
- emty file for future use of servlet
- none of these
How to maintain session in servlet
- http session
- cookies
- URL rewriting, hiddenform fields
- httpsession,hiddenform fields,rewriting,cookies
Which type is preferable to maintain session
- cookies because user can turn off it
- hidden form field because of its performance is moderate
- httpsession because no limit for session data and performance is good
- Url rewriting becasue its easy
Is it possible to servlet have a constructor
- yes but then serlvet will not work properly ie can't provide initilization parameters
- not possible
- sometimes only
- none of these
Difference between GenericServlet and Httpservlet class
- GenericServlet normal purpose HttpSerlvet for complex process
- both are same but parameters are different
- both of above
- GenericServlet is protocol independent, HttpServlet is protocol dependent
differnce between sendRedirect() and forward()
- sendRedirect for redirect request on server side forward process
- SendRedirect on client side process and forward on browser side process
- sendRedirect for slow and forward for fast
- none of these
different between getRequestDispatcher() javax.servlet.servletRequest and javax.servlet.servletContext
- javax.servlet.servletRequest accepts relative path and javax.servlet.servletContext doesn't accepts relative path
- both are same
- javax.servlet.servletRequest for include and javax.servlet.servletContext for forward
- all of above