Tag: web technology

Questions Related to web technology

What method can be used to retrieve all the parameter names being sent as part of the request by the client?

  1. Use the method 'HttpServletRequest.getParameterNames()' which will return an enumeration of parameter names.

  2. Use the method 'HttpServletResponse.getParameterNames()' which will return an enumeration of parameter names.

  3. Use the method 'HttpServletRequest.getAllParameters()' which will return an enumeration of parameter names.

  4. There is no direct support in the Servlet API to retrieve the name of all the parameters sent by the client.


Correct Option: A

What will be the output of the following JSP code snippet at run-time when it is accessed the third time? The value of test is

  1. The value of the 'test' variable will be 2.

  2. The value of the 'test' variable will be 0.

  3. The value of the 'test' variable will be 1.

  4. The variable 'test' must be declared at global scope, else a run-time error will occur


Correct Option: C

Following is an excerpt taken from a Deployment Descriptor of some Web Application. app-name MockQuestions ContextInfoServlet scwcd14.chap03.ContextInfoServlet app-name ContextInfoServlet Which of the following code will output the message 'MockQuestions ContextInfoServlet' to the client browser (assuming that 'out' is a valid instance of type 'PrintWriter' class)?

  1. out.println(config.getServletContext().getParameter("app-name")); out.println(config.getInitParameter("app-name"));

  2. out.println(config.getInitParameter("app-name")); out.println(config.getServletContext().getInitParameter("app-name"));

  3. out.println(config.getServletContext().getInitParameter("app-name")); out.println(config.getInitParameter("app-name"));

  4. out.println(config.getServletContext().getInitParameter("app-name")); out.println(config.getParameter("app-name"));


Correct Option: C

Which of the following EL expression retrieves the value of the attribute by name 'attribute' found in HTTP's request object

  1. ${request.getAttribute()}

  2. ${request.attribute}

  3. ${pageContext.request.getAttribute()}

  4. ${pageContext.request.attribute}


Correct Option: D

What method can be used to retrieve all the parameter names being sent as part of the request by the client?

  1. Use the method 'HttpServletRequest.getParameterNames()' which will return an enumeration of parameter names.

  2. Use the method 'HttpServletResponse.getParameterNames()' which will return an enumeration of parameter names.

  3. Use the method 'HttpServletRequest.getAllParameters()' which will return an enumeration of parameter names.

  4. There is no direct support in the Servlet API to retrieve the name of all the parameters sent by the client.


Correct Option: A

What is the equivalent action code for the following piece of JSP code snippet? EmployeeBean harry = (EmployeeBean)request.getAttribute("harry"); if (harry == null) { harry = new EmployeeBean(); request.setAttribute("harry", harry); }


Correct Option: C

Which of the following EL expression retrieves the value of the attribute by name 'attribute' found in HTTP's request object

  1. ${request.getAttribute()}

  2. ${request.attribute}

  3. ${pageContext.request.getAttribute()}

  4. ${pageContext.request.attribute}


Correct Option: D
  1. The value of the 'test' variable will be 2.

  2. The value of the 'test' variable will be 0.

  3. The value of the 'test' variable will be 1.

  4. The variable 'test' must be declared at global scope, else a run-time error will occur


Correct Option: C
  1. The Servlet will output 'javabeat null' in the Server Console.

  2. The Servlet will fail to load as the init param property 'no-name' is not mentioned in the deployment descriptor

  3. A NullPointerException will be raised as calling getServletConfig() in the init() method will return a null reference.

  4. The Servlet will output 'javabeat ' in the Server Console.


Correct Option: A