Java Web Technologies: JSP, Servlets & Application Servers
Test your knowledge of Java web development including JSP expressions, Servlet API, deployment descriptors, design patterns, and application server configuration.
Questions
An external JMS client is connected to a 2 managed server weblogic cluster using a Connection Factory that has server affinity enabled. The client is putting messages to a distribution destination (dd) deployed to the cluster. Which managed server(s) dd member will get the messages?
- The managed server which was used by the client for JNDI lokkup of the connection factory
- The managed server to which the client has a TCP connection after creating a new connection from the connection factory.
- Both the managed servers and in random order
- Only to One of the managed server and that can be in any order
Which program do you need to write HTML?
- Graphic designer
- Any text editor
- browsers
- all of the above
What tag tells the browser where the page starts and stops ?
- <head>
- <body>
- <html>
- both 1 & 2
Find the odd one
- STRUTS
- SPRINGS
- DOJO
- FLEX
Pick the odd one
- CPP
- JAVA
- SMALL TALK
- C
Odd one out
- JAR
- PAR
- DAR
- WAR
Pick the odd one
- ZEUS
- JIGSAW
- LIGHTTP
- WEBLOGIC
Pick the odd one
- JBOSS
- JRUN
- XITAMI
- GLASS FISH
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); }
- <jsp:declareBean id = "harry" class = "EmployeeBean" scope = "request" />
- <jsp:createBean id = "harry" class = "EmployeeBean" />
- <jsp:useBean id = "harry" class = "EmployeeBean" scope = "request" />
- <jsp:useBean id = "harry" class = "EmployeeBean" />
Which of the following is a valid declaration of a Tag Library in a Deployment Descriptor?
- <taglib> <uri>http://www.javabeat.net/studyKit</uri> <location>/studyKit.tld</location> </taglib>
- <taglib> <uri>http://www.javabeat.net/studyKit<uri> <location>/studyKit.tld</location> </taglib>
- <taglib> <taglib-uri>http://www.javabeat.net/studyKit</taglib-uri> <taglib-location>/studyKit.tld</taglib-location> </taglib>
- <taglib> <uri>http://www.javabeat.net/studyKit</uri> <path>/studyKit.tld</path> </taglib>
A class wants to keep track of its number of objects being added to HttpSession objects. Which will be the ideal way to achieve this?
- Define a listener class implementing HttpSessionListener and whenever an object is added to Http Session object, keep track of the number of instances.
- Define a listener class implementing HttpSessionBindingListener and in the valueBound() method, keep track of the number of instances being added in a static variable.
- It is highly impossible to keep track the number of objects being added to a Http Session in a Web Application.
- The Servlet API provides direct support for keeping track the object instances.
What method can be used to retrieve all the parameter names being sent as part of the request by the client?
- Use the method 'HttpServletRequest.getParameterNames()' which will return an enumeration of parameter names.
- Use the method 'HttpServletResponse.getParameterNames()' which will return an enumeration of parameter names.
- Use the method 'HttpServletRequest.getAllParameters()' which will return an enumeration of parameter names.
- There is no direct support in the Servlet API to retrieve the name of all the parameters sent by the client.
What will be the output of the following JSP code snippet at run-time when it is accessed the third time? <% int test = 0; %> <% ++test; %> The value of test is <%= test %>
- The value of the 'test' variable will be 2.
- The value of the 'test' variable will be 0.
- The value of the 'test' variable will be 1.
- The variable 'test' must be declared at global scope, else a run-time error will occur
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)?
- out.println(config.getServletContext().getParameter("app-name")); out.println(config.getInitParameter("app-name"));
- out.println(config.getInitParameter("app-name")); out.println(config.getServletContext().getInitParameter("app-name"));
- out.println(config.getServletContext().getInitParameter("app-name")); out.println(config.getInitParameter("app-name"));
- out.println(config.getServletContext().getInitParameter("app-name")); out.println(config.getParameter("app-name"));
Which of the following EL expression retrieves the value of the attribute by name 'attribute' found in HTTP's request object
- ${request.getAttribute()}
- ${request.attribute}
- ${pageContext.request.getAttribute()}
- ${pageContext.request.attribute}
A software company wants to develop a component that does many of the pre-processing stuffs like whether the requests are coming from authentic sources, filtering unwanted data in the request object. What type of pattern will be the best match for developing such a component?
- Front Controller
- Business Controller
- Business Delegate
- Intercepting Filter
What method can be used to retrieve all the parameter names being sent as part of the request by the client?
- Use the method 'HttpServletRequest.getParameterNames()' which will return an enumeration of parameter names.
- Use the method 'HttpServletResponse.getParameterNames()' which will return an enumeration of parameter names.
- Use the method 'HttpServletRequest.getAllParameters()' which will return an enumeration of parameter names.
- There is no direct support in the Servlet API to retrieve the name of all the parameters sent by the client.
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); }
- <jsp:declareBean id = "harry" class = "EmployeeBean" scope = "request" />
- <jsp:createBean id = "harry" class = "EmployeeBean" />
- <jsp:useBean id = "harry" class = "EmployeeBean" scope = "request" />
- <jsp:useBean id = "harry" class = "EmployeeBean" />
Which of the following EL expression retrieves the value of the attribute by name 'attribute' found in HTTP's request object
- ${request.getAttribute()}
- ${request.attribute}
- ${pageContext.request.getAttribute()}
- ${pageContext.request.attribute}