Tag: web technology

Questions Related to web technology

  1. A Servlet is a Server-side entity that will rest only on the Server.

  2. The life-cycle management of Servlets is done by the programmer.

  3. Java Servlet Technology provides support for handling XML requests through a special Servlet called XmlServlet.

  4. A Servlet instance is created by the client during the first request to the Servlet Container.


Correct Option: A
  1. session-timeout

  2. session-min-time

  3. session-inactive-time

  4. session-interval-time


Correct Option: A
  1. A listener for HttpSession cannot be specified statically inside a Deployment Descriptor, instead it can be programmatically mentioned.


Correct Option: B
  1. ServletContextListener

  2. ApplicationListener

  3. ApplicationContextListener

  4. None of the above.


Correct Option: A
  1. HttpSession.setMinInactiveInterval(10);

  2. HttpSession.setMinInactiveInterval(10 * 60);

  3. HttpSession.setMaxInactiveInterval(10 * 60);

  4. HttpSession.setMaxInactiveInterval(10);


Correct Option: C
  1. HttpServletRequest.getWriter();

  2. HttpServlerResponse.getCharacterWriter();

  3. HttpServetRequest.getOutputStream()

  4. HttpServletResonse.getWriter();


Correct Option: D
  1. Place the file 'secret.txt' in a directory called 'protected' in the 'myApp' Web Application.

  2. Place the file 'secret.txt' in a directory called 'private' in the 'myApp' Web Application.

  3. Place the file 'secret.txt' in a directory called 'WEB-INF' in the 'myApp' Web Application.

  4. Any filename starting with 'secret' are usually not accessible by the Clients, so this file can be places anywhere in the Web Application.


Correct Option: C
  1. getAttributeNames()

  2. getAllAttributes()

  3. It is not possible to retrieve all the attributes in one call.

  4. getAttributes()


Correct Option: A
  1. An IllegalStateException exception will be thrown because of the presence of

  2. A second call to setAttribute() with the same attribute name will just replace the

  3. The behavior is not defined in the Servlet Specification.

  4. None of the above.


Correct Option: B
Explanation:

To answer this question, the user needs to know about the HttpSession and its setAttribute() method.

Option A: This option is incorrect. IllegalStateException is thrown when we try to set an attribute on an already invalidated session, not when we set an attribute with the same name.

Option B: This option is correct. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.

Option C: This option is incorrect. The Servlet Specification does define the behavior of HttpSession.setAttribute() method when it is called the second time with the same attribute name.

Option D: This option is incorrect as option B is the correct answer.

Therefore, the correct answer is:

The Answer is: B. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.