Servlet Objective Questions and Answers (SET - 3)
Please attempt at least 12 objective questions to see the test result.
1) Name the location of compiled class files within a war file? Select the one correct answer.
2) I have a web application on tomcat. Here many servlets open their own separate connection to database. To optimize this application, I decided to ask all servlet developers to use same db connection. I need to initialize this connection, before any servlet / jsp will be accessed. I got following suggestions from my developers. Which is the best way to do it?
3) I have an attribute class Class User{ String name; String address; String phoneNo; boolean isLogged; } This class will be added to the session when user logs in and removed from the session when user logs out. I want its isLogged flag to be changed when user login and logs out. Using which listener I can do it?
4) Which of the following statement is correct. Select the one correct answer.
5) To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer.
6) When using HTML forms which of the folowing is true for POST method? Select the one correct answer.
7) HttpServlet extends
8) Which statement is false ?
9) Which of the following code retrieves the Internet Protocol (IP) address of the client that sent the request?
10) Which of the following code can be used to force any content in the buffer to be written to the client?
11) Which element of web.xml is used to specify the error handler in servlets?
12) Which of the following is true about javax.servlet.error.message?
13) Which of the following code is used to set auto refresh of a page after 5 seconds?
14) How can we get context init parameter and run some code before rest of the application can service a client?
15) If you want to track active session or how many users are there? So which listener you should use.