Está en la página 1de 17

Question No :1 For a given ServletResponse response, which retrieves an object for writing binary data?

(Choose correct one from multiple below) 1. response.getWriter() 2. response.getOutputStream() 3. response.getOutputWriter() 4. response.getWriter().getOutputSTream() correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :2 Which retrieves all cookies sent in a given HttpSErvletRequest request? (Choose correct one from multiple below) 1. request.getCookies() 2. request.getAttributes() 3. request.getSession ().getCookies() 4. request.getSession (). GetAttributes() correct is :1 Explanations :request.getCookies() -----------------------------------------------------------------------------Question No :3 Which prevent a servlet from handling requests.? (Choose correct one from multiple below) 1. The servlet's init method does NOT return within a time period defined by the servlet container. 2. The servlet's init method throws a Servlet Exception 3. The servlet's init method sets the Servlet Response's context length to 0 4. 1 and 2 correct is :4 Explanations :The servlet's init method does NOT return within a time period defined by the servlet container. The servlet's init method throws a Servlet Exception

-----------------------------------------------------------------------------Question No :4 A JSP page needs to instantiate a JavaBean to be used by only that page. Which jsp:useBean attributes must be used to access this attribute in the JSP page?

(Choose correct one from multiple below) 1. id 2. type 3. class 4. 1 and 3 correct is :4 Explanations :Same page don't need scope -----------------------------------------------------------------------------Question No :5 In form-based authentication, what must be included in the HTML returned from the URL specified by the <login-page> element? (Choose correct one from multiple below) 1. a base-64 encoded user name and password 2. a form that POSTs to the j_security_check URL 3. an applet that requests the user name and password from the user 4. a hidden field that supplies the login-constraint used by the application correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :6 Which security mechanisms protect the response stream? (Choose correct one from multiple below) 1. data integrity 2. confidentiality 3. authentication 4. 1 and 2 correct is :4 Explanations :data integrity and confidentiality protect the response stream -----------------------------------------------------------------------------Question No :7 Which pieces of information are needed when declaring the web resource collection in the deployment descriptor? (Choose correct one from multiple below) 1. the URL pattern that requires authorization 2. the HTTP methods that require authorization 3. the users allowed access to the web resource 4. 1 and 2 correct is :4

Explanations :No expl -----------------------------------------------------------------------------Question No :8 When using a form-based authentication, which action must be used in the login form? (Choose correct one from multiple below) 1. j_login 2. j_login_check 3. j_get_security 4. j_security_check correct is :4 Explanations :j_security_check -----------------------------------------------------------------------------Question No :9 Which security mechanism is employed only on the server-side to limit access to resources or components? (Choose correct one from multiple below) 1. authorization 2. data integrity 3. confidentiality 4. authentication correct is :1 Explanations :authorization -----------------------------------------------------------------------------Question No :10 Which element of a web application deployment descriptor <security-constraint> element is required? (Choose correct one from multiple below) 1. <web-resource-collection> 2. <transport-guarantee> 3. <security-role> 4. <auth-method> correct is :1 Explanations :No expl -----------------------------------------------------------------------------Question No :11 Given: <%-- insert code here --%> <html> <body>

Today is: <%= new Date() %> </body> </html> What needs to go on line 1? (Choose correct one from multiple below) 1. <%@ page import='java.util.Date' %> 2. <%@ import class='java.util.Date' %> 3. <%@ include file='java.util.Date' %> 4. <%@ include class='java.util.Date' %> correct is :1 Explanations :No expl -----------------------------------------------------------------------------Question No :12 Which occur during JSP page translation? (Choose correct one from multiple below) 1. The JSP page implementation class is created. 2. The JSP page implementation class is compiled. 3. The JSP page is validated for syntatic correctness. 4. All of the above correct is :4 Explanations :All -----------------------------------------------------------------------------Question No :13 Given the web application deployment descriptor: 1 <jsp-config> 2 <jsp-property-group> 3 <url-pattern>*.jsp</url-pattern> 4 <scripting-invalid>false</scripting-invalid> 5 </jsp-property-group> 6 </jsp-config> and test.jsp: 10 x 5 = ${10 * 5}<br> 2 * 3 = <%= 2 * 3 %><br> What is the result? (Choose correct one from multiple below) 1. An error occurs during page translation. 2. Translation is successful, but nothing is included in the response. 3. Both "10 x 5 = 50" and "2 * 3 = 6" are included in the JSP response. 4. The text "10 x 5 = 50" is included in the JSP response, but "2 * 3 = 6" is NOT. correct is :3

Explanations :No expl -----------------------------------------------------------------------------Question No :14 Given: <%@ page autoFlush="true" %< Which is equivalent? (Choose correct one from multiple below) 1. <jsp:page autoFlush="true" /> 2. <jsp:directive.page autoFlush="true" /> 3. <jsp:page.directive autoFlush="true" /> 4. <jsp:directive name ="page"> correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :15 Given that login.getName() returns a java.lang.String value and given the JSP code: Welcome <%= login.getName() %> Which is equivalent? (Choose correct one from multiple below) 1. Welocome <% out.print(login.getName();%> 2. Welocome <% Writer.print(login.getName();%> 3. Welocome <% response.out.print(login.getName();%> 4. Welocome <% response.writer.print(login.getName();%> correct is :1 Explanations :<% out.print(login.getName();%> is same as <%= login.getName() %> -----------------------------------------------------------------------------Question No :16 The JSP developer wants a comment to be visible in the final output to the browser. Which comment style needs to be used in a JSP page? (Choose correct one from multiple below) 1. <% /** this is a comment **/ %> 2. <%-- this is a comment -- %> 3. <% // this is a comment %> 4. <!-- this is a comment --> correct is :4 Explanations :<!-- this is a comment --> This is html comment can be seen on view source. -----------------------------------------------------------------------------Question No :17

Which EL expression evaluates to the request URI? (Choose correct one from multiple below) 1. ${pageContext.request.requestURI} 2. ${requestScope.request.request.URI} 3. ${requestScope.requestURI} 4. ${request.requestURI} correct is :1 Explanations :The request's URI (obtained from > HttpServletRequest): ${pageContext.request.requestURI} -----------------------------------------------------------------------------Question No :18 Given an EL function foo, in namespace func, that requires a long as a parameter and returns a Map, which are valid invocations of function foo? (Choose correct one from multiple below) 1. ${func:foo("3").name} 2. ${func:foo(2)} 3. ${foo(5):func} 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :19 A web application allows the HTML title banner to be set using a servlet context initialization parameter called titleStr. Which properly set the title in this scenario? (Choose correct one from multiple below) 1. <title>${initParam.titleStr}</title> 2. <title>${initParam['titleStr']}</title> 3. <title>${paramValues.titleStr}</title> 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :20 Given: 1 <%java.util.Map map = new java.util.HashMap(); 2 request.setAttribute("map", map); 3 map.put("a","b"); 4 map.put("b","c");

5 map.put("c","d");%> 6 <%-- insert code here -- %> Which EL expressions, inserted at line 6, are valid and evaluate to "d"?

(Choose correct one from multiple below) 1. ${map.c} 2. ${map["c"]} 3. ${map[map.b]} 4. All of the above correct is :4 Explanations :All -----------------------------------------------------------------------------Question No :21 Within a web application deployment descriptor, which maps the com.example.LoginServlet servlet to /test/LoginServlet? (Choose correct one from multiple below) 1. <servlet> <servlet-class>com.example.LoginServlet</servlet-class> <url-pattern>/test/LoginServlet</url-pattern> </servlet> 2. <servlet-mapping> <servlet-class>com.example.LoginServlet</servlet-class> <url-pattern>/test/LoginServlet</url-pattern> </servlet-mapping> 3. <servlet> <servlet-mapping> <servlet-class>com.example.LoginServlet</servlet-class> <servlet-name>Login Servlet</servlet-name> <url-pattern>/test/LoginServlet</url-pattern> </servlet-mapping> </servlet> 4. <servlet> <servlet-name>Login.Servlet</servlet-name> <servlet-class>com.example.LoginServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Login.Servlet</servlet-name> <url-pattern>/test/LoginServlet</url-pattern> </servlet-mapping>

correct is :4 Explanations :check web.xml -----------------------------------------------------------------------------Question No :22 Which element, defined as a child of a <servlet> element in the web application deployment descriptor, guarantees a servlet will be initialized at the time the application is deployed? (Choose correct one from multiple below) 1. <load-on-startup/> 2. <load-on-startup>1</load-on-startup> 3. <load-on-startup>-1</load-on-startup> 4. <load-on-startup>true</load-on-startup> correct is :2 Explanations :load-on-startup value should be positive integer -----------------------------------------------------------------------------Question No :23 Which path is required to be present within a WAR file? (Choose correct one from multiple below) 1. /classes 2. /index.html 3. /WEB-INF/web.xml 4. /WEB-INF/classes correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :24 In which web application directories can dependent classes and libraries be located? (Choose correct one from multiple below) 1. /WEB-INF/lib as a JAR file 2. /WEB-INF/classes as compiled class files 3. /WEB-INF/lib as compiled class files 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :25 Which are described in the standard web application deployment descriptor? (Choose correct one from multiple below) 1. session configuration

2. MIME type mappings 3. ServletContext initialization parameters 4. All of the above correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :26 Which defines the welcome files in a web application deployment descriptor? (Choose correct one from multiple below) 1. <welcome> <welcome-file>/welcome.jps</welcome-file> </welcome> <welcome> <welcome-file>/index.html</welcome-file> </welcome> 2. <welcome-file-list> <welcome-file>welcome.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> 3. <welcome> <welcome-file>welcome.jsp</welcome-file> </welcome> <welcome> <welcome-file>index.html</welcome-file> </welcome> 4. <welcome-file-list> <welcome-file>/welcome.jsp</welcome-file> <welcome-file>/index.html</welcome-file> </welcome-file-list> correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :27 In which locations can library dependencies be defined for a web application? . (Choose correct one from multiple below) 1. the web application deployment descriptor 2. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath 3. the /META-INF/MANIFEST.MF manifest file 4. 2 and 3 correct is :4

Explanations :No -----------------------------------------------------------------------------Question No :28 A RequestDispatcher can be obtained from which objects? (Choose correct one from multiple below) 1. ServletConfig 2. ServletContext 3. HttpServletRequest 4. 2 and 3 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :29 A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in a thread-safe manner. Which can support this design goal? (Choose correct one from multiple below) 1. Store the data in a local variable. 2. Store the data in the HttpSession object. 3. Store the data in the ServletRequest object. 4. 1 and 3 correct is :4 Explanations :HttpSession is not thread safe -----------------------------------------------------------------------------Question No :30 Given: 1 <% String value = "beanvalue"; %> 2 <% request.setAttribute ("com.example.bean", value); %> 3 <%-- insert code here --%> Which EL expression, inserted at line 3 is valid and evaluated to "beanValue"? (Choose correct one from multiple below) 1. ${requestScope["com.example.bean"]} 2. ${com.example.bean} 3. ${beanValue} 4. ${bean} correct is :1 Explanations :No expl -----------------------------------------------------------------------------Question No :31

For which events can web application event listeners be registered? (Choose correct one from multiple below) 1. when a session is created 2. when a session has timed out 3. when a session attribute value is changed 4. All of the above correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :32 Servlet A receives a request that it forwards to servlet B within another web application in the same web container. Servlet A needs to share data with servlet B and that data must not be visible to other servlets in A's web application. In which object can the data that A shares with B be stored? (Choose correct one from multiple below) 1. HttpSession 2. ServletConfig 3. ServletContext 4. HttpServletRequest correct is :4 Explanations :HttpServletRequest -----------------------------------------------------------------------------Question No :33 Which are true about the HttpServletRequestWrapper class? (Choose correct one from multiple below) 1. The HttpServletRequestWrapper is an example of the Decorator pattern. 2. The HttpServletRequestWrapper can be used to extend the functionally of a servlet request. 3. An HttpServletRequestWrapper may be used only by a class implementing the javax.servlet.Filter interface. 4. All of the above correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :34 Which is the correct web application deployment descriptor element for defining a servlet initialization parameter? (Choose correct one from multiple below)

1. <init-param> <param-name>timeout</param-name> <param-value>1000</param-value> </initparam> 2. <servlet-param> <param-name>timeout</param-name> <param-value>1000</param-value> </servlet-param> 3. <init-parameter> <parameter-name>timeout</parameter-name> <parametervalue>1000</parametervalue> </init-parameter> 4. <servlet-parameter> <parameter-name>timeout</parameter-name> <parametervalue> 1000</parameter-value> </servlet-parameter> correct is :1 Explanations :No expl -----------------------------------------------------------------------------Question No :35 A developer is designing a multi-tier web application and discovers a need to log each incoming client request. Which patterns, taken independently, provide a solution for this problem? (Choose correct one from multiple below) 1. Transfer Object 2. Service Locator 3. Front Controller 4. Intercepting Filter correct is :3 Explanations :No expl -----------------------------------------------------------------------------Question No :36 A developer is designing a web application that makes many fine-grained remote data requests for each client request. During testing, the developer discovers that the volume of remote requests significantly degrades performance of the application. Which design pattern provides a solution for this problem? (Choose correct one from multiple below) 1. Flyweight 2. Transfer Object 3. Service Locator 4. Dispatcher View correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :37 Which design pattern is used to call business objects ?

(Choose correct one from multiple below) 1. Transfer Object 2. Service Locator 3. Intercepting Filter 4. Business Delegate correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :38 A developer is designing a web application that must support multiple interfaces, including: 1 an XML web service for B2B 2 HTML for web-based clients 3 WML for wireless customers Which design pattern provides a solution for this problem?

(Choose correct one from multiple below) 1. Session Facade 2. Business Delegate 3. Data Access Object 4. Model-View-Controller correct is :4 Explanations :No -----------------------------------------------------------------------------Question No :39 Which are valid values for the body-content attribute of a tag directive in a tag file? (Choose correct one from multiple below) 1. empty 2. scriptless 3. tagdependent 4. All of the above correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :40 Which interface must a class implement so that instances of the class are notified after any object is added to a session?

(Choose correct one from multiple below) 1. javax.servlet.http.HttpSessionListener 2. javax.servlet.http.HttpSessionValueListener 3. javax.servlet.http.HttpSessionBindingListener 4. javax.servlet.http.HttpSessionAttributeListener correct is :3 Explanations :javax.servlet.http.HttpSessionBindingListener -----------------------------------------------------------------------------Question No :41 Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the message "File not found". An error page has been configured for this JSP page. Which option prevents the exception thrown by my:errorProne from invoking the error page mechanism and outputs the message "File not found" in the response? (Choose correct one from multiple below) 1. <c:try catch="ex"> <my:errorProne /> </c:try> ${ex.message} 2. <c:catch var="ex"> <my:errorProne /> </c:catch> ${ex.message} 3. <c:try> <my:errorProne /> </c:try> <c:catch var ="ex" /> ${ex.message} 4. None of the above correct is :2 Explanations :No expl -----------------------------------------------------------------------------Question No :42 Given that a scoped attribute cart exists only in a user's session, which, taken independently, ensure the scoped attribute cart no longer exists? (Choose correct one from multiple below) 1. <c:remove var="cart" scope="session" /> 2. <c:remove scope="session">cart</c:remove> 3. <c:remove var="${cart}" scope="session" /> 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :43 Given in a single JSP page: <%@ taglib prefix='java' uri='myTags' %> <%@ taglib prefix='JAVA' uri='moreTags' %> Which are true?

(Choose correct one from multiple below) 1. The prefix 'java' is reserved. 2. The URI 'myTags' must be properly mapped to a TLD file by the web container. 3. A translation error occurs because the prefix is considered identical by the web container. 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :44 Which are true about the JSTL core iteration custom tags?

(Choose correct one from multiple below) 1. When looping over collections, a loop status object may be used in the tag body. 2. It may iterate over arrays, collections, maps and strings. 3. The body of the tag may contain EL code, but not scripting code. 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :45 A web application contains a tag file called beta.tag in/WEB-INF/tags/alpha. A JSP page called sort.jsp exists in the web application and contains only this JSP code: 1 <%@ taglib prefix="x" 2 tagdir="/WEB-INF/tags/alpha" %> 3 <x:beta /> The sort.jsp page is requested. Which are true? (Choose correct one from multiple below) 1. The tagdir attribute in line 2 can be replaced by a uri attribute if a TLD referring to beta.tag is created and added to the web application. 2. The sort.jsp page translates successfully and invokes the tag defined by beta.tag. 3. Tag files can only be accessed using a tagdir attribute. 4. 1 and 2 correct is :4 Explanations :No expl -----------------------------------------------------------------------------Question No :46 Which statement is true about web container session management? (Choose correct one from multiple below)

1. Access to session-scoped attributes is guaranteed to be thread-safe by the web container. 2. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewriting method. 3. If the web application uses HTTPS, then the web container may use the data on the HTTPS request stream to identify the client. 4. The JSESSIONID cookie is stored permanently on the client so that a user may return to the web application and the web container will rejoin that session correct is :3 Explanations :No expl -----------------------------------------------------------------------------Question No :47 Given the service method of an HttpServlet: 1 public void service(HttpServletRequest request, 2 HttpServletResponse response) 3 throws ServletException, IOException { 4 Httpsession s = request.getSession(); 5 // insert code here 6} Which statement, inserted at line 6, unbinds an attribute from a session? (Choose correct one from multiple below) 1. session.unbind("key"); 2. session.remove("key"); 3. session.removeAttribute("key"); 4. session.unbindAttribute("key"); correct is :3 Explanations :No expl -----------------------------------------------------------------------------Question No :48 Given the definition of MyServlet: 1 public class MyServlet extends HttpServlet { 2 public void service(HttpServletRequest request, 3 HttpServletResponse response) 4 throws ServletException, IOException { 5 HttpSession session = request.getSession() 6 session.setAttribute("myAttribute", "myAttributeValue"); 7 session.invalidate(); 8 response.getWriter().println("value=" + 9 session.setAttribute("myAttribute")); 10 }

11 } What is the result when a request is sent to MyServlet? (Choose correct one from multiple below) 1. An IllegalStateException is thrown at runtime. 2. An InvalidSessionException is thrown at runtime. 3. The string "value=null" appears in the response stream. 4. The string "value=myAttributeValue" appears in the response stream. correct is :1 Explanations :No expl -----------------------------------------------------------------------------Question No :49 Which method must be used to encode a URL passed as an argument to HttpServletResponse.sendRedirect when using URL rewriting for session tracking? . (Choose correct one from multiple below) 1. ServletResponse.encodeURL 2. HttpServletResponse.encodeURL 3. ServletResponse.encodeRedirectURL 4. HttpServletResponse.encodeRedirectURL correct is :4 Explanations :No expl ------------------------------------------------------------------------------

También podría gustarte