Tag: technology

Questions Related to technology

  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. Inside TRY Inside FINALLY

  2. Inside TRY

  3. Inside TRY Inside CATCH Inside FINALLY

  4. None of the above


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.