Question:* If cookies are turned off on the client, which two methods still work with the session ID?
Answer: • encodeRedirectURL()
Answer: • sessionRedirectURL()
Answer: • encodeURL()
Question:* Which two of the following statements are best associated with the HTTPPOST method?
Answer: • There is no limit on how much data this HTTP method can send
Answer: • This method is most often used to submit form data
Question:* Which two statements among the following apply to redirecting a HTTP request to another URL?
Answer: • The path must be relative
Answer: • The redirect method must be called before the response body is committed, otherwise an IllegalStateException is thrown
Question:* Which of the following statements are true regarding the HTTP GET method?
Answer: • There is a limit on how much data this HTTP method can send
Answer: • This HTTP method is the fastest
Question:* Which of the following statements are true regarding declaring a servlet instance in a deployment descriptor?
Answer: • The tags are nested within <web-app> tags
Answer: • It specifies the fully qualified class name of the servlet
Question:* Which of the following statements are true regarding the structure of a WebArchive file?
Answer: • It has a war extension
Answer: • It is extracted by the container upon the first call to any�servlet it contains
Question:* With regard to the service() lifecycle method, identify two correct statements about its purpose or about how and when it is invoked.
Answer: • It is called whenever the servlet is requested
Answer: • It is called after the init method is called
Question:* Read the following code snippet and answer the question based upon it: <taglib> <taglib-uri> http://www.yourcompany.com/you TagLibrary </taglib-uri> <taglib-location> /WEB-INF/yourTagLibrary.tld </taglib-location> </taglib> From the statements given below, which one applies to the code snippet?
Answer: • The taglib directive can reference a TLD by name
Question:* Which method is called by the servlet container just after the servlet is removed from service?
Answer: • public void destroy() {// code...}
Question:* Which statement is true regarding ServletContext Initialization Parameters in the deployment descriptor?
Answer: • They are accessible by all servlets in a given container
Question:* Which method in the HttpServlet class corresponds to the HTTPPOST method?
Answer: • doPost
Question:* What is the file name of the WebApp deployment descriptor?
Answer: • web.xml
Question:* What is the WebApp deployment descriptor element name for the Servlet Context Initialization Parameters?
Answer: • <init-param>
Question:* With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.
Answer: • It gives the servlet an opportunity to clean up resources
Question:* How would you use a bean in a JSP page?
Answer: • <jsp:useBean id="houseLotBean" scope="session" class="session.Realestate"/>
Question:* Which of the following is the name of the cookie used by Servlet Containers to maintain session information?
Answer: • JSESSIONID
Question:* Which design pattern reduces network traffic by acting as a caching proxy of a remote object?
Answer: • Value Object
Question:* Assuming the tag library is in place and the tag handler is correct, which of the following is the correct way to use a custom tag in a JSP page?
Answer: • <yourLibrary:whatColorlslt color="red"/>
Question:* What output will be sent to the browser by the following code snippet? <!-- Que <%="Reader"%> -->
Answer: • This is a comment so it is ignored by the container
Question:* Which of the following are used by Servlet Containers to maintain session information?
Answer: • URL rewriting
Question:* Read the following code snippet: 1 <libraryPrefix:handlerName parameterNAme="value"> 2 <%=23*counter %> 3 <b>Congratulations!</b> Which of the following is the correct way to complete the above code snippet?
Answer: • </libraryPrefix:handlerName>
Question:* In which directory do you place any auxiliary JAR files?
Answer: • WEB-INF/jar
Question:* Which statements are true regarding ServletContext Init Parameters in the deployment descriptor?
Answer: • They are set at deployment-time and can be updated at run-time
Question:* With regard to the servlet context listener, which of the following methods is valid?
Answer: • contextListenerInitialized
Question:* Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how do you get a request parameter in that servlet?
Answer: • String value=req.getParameter("product");
Question:* Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
Answer: • <TWONG:GLOOP/>
Question:* Which of the following is not a JSP implicit object?
Answer: • in
Question:* Which of the following is the listener interface for servlet context attributes?
Answer: • ServletContextListener
Question:* What is Template Data?
Answer: • The plain text (such as HTML) outside JSP tags(non java) in a JSP page
Question:* Which of the following options is a valid declaration?
Answer: • <%! String name="Patricia" %>
Question:* Which of following interfaces can make a servlet thread safe?
Answer: • synchronization
Question:* Which statement is true regarding a servlet context listener?
Answer: • An object that implements a context listener is notified when its Web App context is created or destroyed
Question:* Which of the following options is a valid expression?
Answer: • <%=(new java.util.Date()).toLocaleString() %>
Question:* What does the container do with the following code snippet? <!--#include file="somefile.html"-->
Answer: • The container passes this line of code through to the client
Question:* Which method in the HttpServlet class corresponds to the HTTPPUT method?
Answer: • put
Question:* Which of the following is a JSP implicit object?
Answer: • request
Question:* Which design pattern is used to decouple presentation from core data access functionality?
Answer: • DataAccess Object
Question:* In which directory do you place servlet class files?
Answer: • WEB-INF\classes
Question:* Which design pattern did technical designers of JSP use to provide centralized dispatching of requests via a controller servlet?
Answer: • Model-view-Controller
Question:* Which interface and method name should be used to retrieve HTTP request header information?
Answer: • HttpServletRequest.getHeaderNames
Question:* Which interface provides access to request scoped attributes?
Answer: • ServletContext
Question:* Which JSP action retrieves the value of a property from a properly declared JavaBean in a JSP page?
Answer: • jsp:getProperty
Question:* Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet: 1.public void service(HttpServletRequestrequest, 2.HttpServletResponseresponse) 3.throws ServletException, IOException 4. { 5. 6. } What code would you type on line 5 to return an error message to the requesting client?
Answer: • response.sendError(HTTPServletResponse.SC_FORBIDDEN,"Error");
Question:* Which interface and method name should be used to acquire a text stream for the response?
Answer: • ServletResponse.getOutputStream
Question:* Which among the following objects is the best choice to share information between pages for a single user?
Answer: • request
No comments:
Post a Comment