If a servlet needs to access a shared resource specified in the web application's context parameters, which approach should be used?

  • Access the shared resource through the HttpSession object.
  • Directly access the shared resource using the File class.
  • Use a global variable within the servlet to store the shared resource.
  • Utilize the ServletContext to retrieve the shared resource using getInitParameter().
To access a shared resource specified in the web application's context parameters, a servlet should use the ServletContext and the getInitParameter() method. This ensures proper retrieval of the shared resource.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *