You are on page 1of 2

1. Write the web.xml entry to configure the session timeout to 120 seconds 2. Write the web.

xml entry to configure error.jsp as error page if NumberFormatException occurs in the web module 3. Write the java code snippet to forward a request to welcome.jsp page using request dispatcher 4. Whats the method in servletrequest to get the value entered in multi-value html control like listbox 5. Write the java code snippet to get the reference to httpsession object and add an attribute Attributename=username Attributevalue=amit 6. what is instance pooling/request serialization in servlet container and when does it happen 7. write the java code snippet to create a cookie with name=username and value=amit and add the cookie to the response 8. write the java code snippet to read all the cookie from request and print the cookie names 9. write the java code snippet to explicitly terminate a http session 10. what are the lifecycle methods of a filter

11. write the web.xml entry to define a filter with name=MyFilter and class=example.MyFilter 12. write the web.xml entry to pass the folloing init params to a servlet servlet-name: MyServlet servlet-class=example.MyServlet param name=jndi-datasource param value=MyDatasource 13. whats the difference between sendredirect and forward

14. if theres are requirement to share a variable among different servlet objects participating in different http sessions, to which type of object shall we set it as an attribute a. servletrequest b. httpsession c. servletcontext 15. write the java code snippet to invoke the next filter from a filters doFilter method 16. a servlet object can be associated with more than one servletconfig object a. yes b. no 17. a servlet context can be associated with more than one servlet object a. yes b. no 18. in web.xml, a servlet can be mapped with multiple url-pattern a. yes b. no when do we need to implement the singlethreadmodel interface

19.

20. if load on startup is not configured, when is the servlet object created by the container a. When the web container starts up b. When the first request comes for the servlet

Note: A java code snippet should be a block of required code and not a complete program. Similarly, web.xml entry should be the required xml fragment and not the whole web.xml content. Please ensure, the class/interface/method names are in proper case in our answers

You might also like