Given the element from the web application deployment descriptor:
<jsp – property – group>
<url – pattern>/main/page1.jsp</url – pattern>
<scripting – invalid>true</scripting – invalid>
</jsp—property—group>
And given that /main/page1.jsp contains:
<% int i = 12; %>
<b> <%= i %> </b>
What is the result?
A. <b> <b>
B. <b> l2 </b>
C. The JSP fails to execute.
D. <% int i = 12 %>
<b> <%= i % > < b>
Answer: C
Question: 2
A web application allows the HTML title
banner to be set using a context initialization parameter called titlestr.
Which two properly set the title in the scenario? (Choose two)
A. <title> $ {titlestr} </title>
B. <title> $
{initparam.titlestr}</title>
C. <title> $ {param [0]. titlestr}
</title>
D. <title> $ {paramValues.titleStr}
</title>
E. <title> $ {initParam [‘titleStr’]
} </title>
F. <title> $
{servletParams.titleStr} </title>
G. <title> $ {request.get
(“titleStr”) } </title>
Answer: B & E
Question: 3
Given:
11. <%
12. request.setAttribute
(“vals”, new String[] {“1”, “2”, “3”, “4”});
13. request.setAttribute
(“index”, “2”);
14. %>
15. <% - - insert code here - - %>
Which three EL expressions, inserted at line 15, are valid and evaluate to “3”? (Choose three)
A. ${vals.2}
B. ${vals [“2”] }
C. ${vals.index}
D. ${vals[index] }
E. ${vals} [index]
F. ${vals. (vals.index) }
G. ${vals [vals[index-1]] }
Answer: B & D & G
Question : 4
Which three EL expressions, inserted at line 16, are valid and evaluate to “d”? (Choose three)
A. ${map.c}
B. ${map.[c]}
C. ${map.[“c”]}
D. ${map.map.b}
E. ${map.[map.b]}
F. ${map. (map.b)}
Answer: A & C & E
Question: 5
You are building a dating service web
site. Part of the form to submit a client's profile is a group of radio buttons
for the person's hobbies:
20. <input type = ‘radio’ name = ‘hobbyEnum’ value =
‘HIKING’> Hiking <br>
21. <input type = ‘radio’ name = ‘hobbyEnum’ value =
‘SKING’> Sking <br>
22. <input type = ‘radio’ name = ‘hobbyEnum’ value =
‘SCUBA’> SCUBA <br>
23. <! - - and more options - -
>>
After the user submits this form, a confirmation screen is displayed with these hobbies listed. Assume that an application-scoped hobbies, holds a map between the hobby enumerated type and the display name. Which EL code snippet will display Nth element of the user's selected hobbles?
A. ${hobbies [hobbyEnum[N]}
B. ${hobbies [paramValues.hobbyEnum[N]]}
C. ${hobbies [paramValues @ ‘hobbyEnum’
@N]
D. ${hobbies.get(paramValues.hobbyEnum[N])
}
E. ${hobbies
[paramValues.hobbyEnum.get(N)] }
Answer: B
Question: 6
Given:
1.
<% int[] nums = {42,420,4200};
2. request.setAttribute("foo",
nums); %>
3.
${5 + 3 It 6}
4.
S(requestScope['foo'][0] ne 10 div0>
5.
${10 div 0}
What is the result?
A. true
true
B. false
true
C. false
true 0
D. true
true Infinity
E. false
true Infinity
F. An exception is thrown
G. Compilation or translation fails
Answer: E
Question: 7
You are building a web application with a
scheduling component. On the JSP, you need to show the current date, the date
of the previous week, and the date of the next week. To help you present this
information, you have created the following EL functions in the ‘d’ namespace:
• Name
: curData; signature: java.util.utilDate CurrentDate()
• Name
: curData; signature: java.util.utilDate addweek (java.util.Date, int)
• Name:
dateString; signature: java.util.String getDataString (jave.util.Data)
Which EL code snippet will generate the string for the previous week?
A. ${d:dateString(affWeek(curDate(), -1))
}
B. ${d:dateString [addWeek[curDate[], - ]]
}
C. ${d:dateString [d:addWeek[d:curDate[],
- 1]] }
D. ${d:dateString (d:addWeek(d:curDate(),
-1)) }
Answer: D
Question: 8
Given a header in an HI IP request:
X-Retries: 4
A Which two retrieve the value of the header from a given HttpServletRequest request? (Choose two)
A. request-getHeader("X-Retries")
B.
request.getlntHeader("X-Retries")
C.
request.getRequestHeader("X-Retries")
D.
request.getHeaders{"X-Retries").get(0)
E.
request.getRequestHeaders("X-Retries").get(0)
Answer: A & B
Question: 9
Given an HttpServletRequestrequest and
HttpResponseresponse, which sets a cookie “username” with the value “joe” in a
servlet?
A. request.addCookie("username",
"joe")
B. request.setCookie("username",
"joe")
C.
response.addCookie("username", "joe")
D. request.addHeader(new
Cookie("username", "joe"))
E. request.addCookie(new
Cookie("username", "joe"))
F. response.addCookie(new
Cookie("username", "joe"))
G. response.addHeader(new
Cookie("username", "joe"))
Answer: F
Question: 10
Which annotation enables a servlet to
efficiently process requests of typo multipart/form-data that involve large
files being uploaded by the client?
A. @AcceptMultipart
B. @MultiPartConfig
C. @MultiPartFormData
D. @WebServlet (multipart = true)
Answer: B
Question: 11
APIs for dynamically registering servlets
and filters can be called at:
A. Context initialization time
B. Any time
C. There is no way to dynamically register
servlets and filters
D. Context destruction time
E. Injected into a servlet context
Answer: A
Question: 12
ServletRegistration.Dynamic can be used to
configure (Choose two)
A. Filter mappings
Answer: A & B
Question: 13
A web application wants to register a new servlet at runtime using one of theservletContext.addServlet methods.In the implementation of which method is it legal to perform this operation?
A. AsyncListner.oncomplete
B. Servlet.init
C. ServletContextListener.contextInitialize
D. ServletrequestListener.contextInitialize
Answer: C
Question: 14
You want to create a filter for your web application and your filter will implement.servlet.Filter.Which two statements are true? (Choose two)
A. Your filter class must implement an init method and a destroy method.
B. Your filter class must also implement javax.sarvlat.FilterChain.
C. When your filter chains to the next filter, it should pass the same arguments it received in itsdoFilter method.
D. The method that your filter invokes on the object it received that implements javax – servlet.Filterchain can invoke either another filter or a servlet.
E. Your filter class must implement a doFilter method that takes, among other things, anHttpServletRequest object and an HttpServletresponse object.
Answer: A,D
Question: 15
You have a simple wpb application that has a single Front Controller servlet that dispatches toJSPs generate a variety of views. Several of these views require further database processing toretrieve the necessary order object using the orderID request parameter. To do this additionalprocessing, you pass the request first to a servlet that is mapped to the URL pattern /WEB – INF / retrieveOrder.do. in the deployment descriptor. This servlet takes two request parameters, theordered and the jspID and the jspURL. It handles the database calls to retrieve and build thecomplex order objects and then it dispatches to the jspURL.
Which code snippet in the Front Controller servlet dispatches the request to the order retrievalservlet?
A. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
= context.getRequestDispathcher (“/WEB – INF / retrieveOrder.do”);
view.forward(request, response)
B. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
Dispatcher view= request.getDispatcher (“.WEB – INF / retrieveOrder.do”);
View.forwardRequest (request, response);
C. String T= “/WEB – INF / retrieveOrder.do?orderID = %d&jspURl = %s”;
String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forward (request, response) ;
D. String T= “/WEB – INF / retrieveOrder.do?orderID = %d&jspURl = %s”;
String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forwardRequest (request, response) ;
Answer: C
Question: 16
In ServletContext.getNamedDispatcher(string arg0) arg0 is the
A. url of a servlet relative to the ServletRequest
B. url of a servlet relative to the Context
C. name of a servlet
D.absolute url to any servlet in any Context
Answer: B
Question: 17
When using Servlet asynchronous API if you want to dispatch the request back to a particular url -"/url" within the same Servlet Context which of the following API would you use?
A. ASyncContext.dispatch();
B. AsyncContext.dispatch("/url");
C. AsyncContext.dispatch(servletContext, "/url");
D. AsyncContext.start(runnable);
E. RequestDispatcher.fotward("/url");
F. RequestDispatcher.forward(servletContext, "/url");
G. RequestDispatcher.include("/url");
Answer: A,C
Reference:http://blogs.oracle.com/enterprisetechtips/entry/asynchronous_support_in_servlet_3(Topic: AsyncContext Class, third paragraph)
Question: 18
Which describes a trigger that causes a call to an AsyncListener?
A. Completion of processing
B. Receipt of a new request from the same client
C. Addition of a new filter to the processing stream for this request
D. Completion of each timer interval
Answer: B
Question: 19
Refer to the Exhibit.
A servletsets a session-scoped attribute product with an instance of com.example.product anforwardto a JSP.Which two output the name of the product in the response? (Choose two)
A. <%= product.getName() %>
B. <jsp:useBean id="product" class="com.example.Product" /><%= product.getName() %>
C. <jsp:useBean id="com.example.Product" scope="page"><%= product.getName() %></jsp:useBean>
D. <jsp:useBean id="product" type="com.example.Product"scope="page" /><%= product.getName() %>
E. <jsp:useBean id="product" type="com.example.Product">
B. add init params
C. set asyncSupported to true
D. add Listeners
Question: 13
A web application wants to register a new servlet at runtime using one of theservletContext.addServlet methods.In the implementation of which method is it legal to perform this operation?
A. AsyncListner.oncomplete
B. Servlet.init
C. ServletContextListener.contextInitialize
D. ServletrequestListener.contextInitialize
Answer: C
Question: 14
You want to create a filter for your web application and your filter will implement.servlet.Filter.Which two statements are true? (Choose two)
A. Your filter class must implement an init method and a destroy method.
B. Your filter class must also implement javax.sarvlat.FilterChain.
C. When your filter chains to the next filter, it should pass the same arguments it received in itsdoFilter method.
D. The method that your filter invokes on the object it received that implements javax – servlet.Filterchain can invoke either another filter or a servlet.
E. Your filter class must implement a doFilter method that takes, among other things, anHttpServletRequest object and an HttpServletresponse object.
Answer: A,D
Question: 15
You have a simple wpb application that has a single Front Controller servlet that dispatches toJSPs generate a variety of views. Several of these views require further database processing toretrieve the necessary order object using the orderID request parameter. To do this additionalprocessing, you pass the request first to a servlet that is mapped to the URL pattern /WEB – INF / retrieveOrder.do. in the deployment descriptor. This servlet takes two request parameters, theordered and the jspID and the jspURL. It handles the database calls to retrieve and build thecomplex order objects and then it dispatches to the jspURL.
Which code snippet in the Front Controller servlet dispatches the request to the order retrievalservlet?
A. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
= context.getRequestDispathcher (“/WEB – INF / retrieveOrder.do”);
view.forward(request, response)
B. reques.setAttribute (“orderID”, orderIS);
request.setAttribute(“jspURL”, jspURL);
Dispatcher view= request.getDispatcher (“.WEB – INF / retrieveOrder.do”);
View.forwardRequest (request, response);
C. String T= “/WEB – INF / retrieveOrder.do?orderID = %d&jspURl = %s”;
String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forward (request, response) ;
D. String T= “/WEB – INF / retrieveOrder.do?orderID = %d&jspURl = %s”;
String url = String.format (T, ordered, jspURL);
= context.getRequestDispatcher (url);
View.forwardRequest (request, response) ;
Answer: C
Question: 16
In ServletContext.getNamedDispatcher(string arg0) arg0 is the
A. url of a servlet relative to the ServletRequest
B. url of a servlet relative to the Context
C. name of a servlet
D.absolute url to any servlet in any Context
Answer: B
Question: 17
When using Servlet asynchronous API if you want to dispatch the request back to a particular url -"/url" within the same Servlet Context which of the following API would you use?
A. ASyncContext.dispatch();
B. AsyncContext.dispatch("/url");
C. AsyncContext.dispatch(servletContext, "/url");
D. AsyncContext.start(runnable);
E. RequestDispatcher.fotward("/url");
F. RequestDispatcher.forward(servletContext, "/url");
G. RequestDispatcher.include("/url");
Answer: A,C
Reference:http://blogs.oracle.com/enterprisetechtips/entry/asynchronous_support_in_servlet_3(Topic: AsyncContext Class, third paragraph)
Question: 18
Which describes a trigger that causes a call to an AsyncListener?
A. Completion of processing
B. Receipt of a new request from the same client
C. Addition of a new filter to the processing stream for this request
D. Completion of each timer interval
Answer: B
Question: 19
Refer to the Exhibit.
A servletsets a session-scoped attribute product with an instance of com.example.product anforwardto a JSP.Which two output the name of the product in the response? (Choose two)
A. <%= product.getName() %>
B. <jsp:useBean id="product" class="com.example.Product" /><%= product.getName() %>
C. <jsp:useBean id="com.example.Product" scope="page"><%= product.getName() %></jsp:useBean>
D. <jsp:useBean id="product" type="com.example.Product"scope="page" /><%= product.getName() %>
E. <jsp:useBean id="product" type="com.example.Product">
<%= product.getName() %>
</jsp:useBean>
Answer: B,D
Question: 20
Click the Exhibit button.Given the HTML form:
1. <html>
2. <body>
3. <form action="submit.jsp">
4. Name: <input type="text" name="i1"><br>
5. Price: <input type="text" name="i2"><br>
6. <input type="submit">
7. </form>
8. </body>
9. </html>
Assume the product attribute does NOT yet exist in any scope.
Which code snippet, in submit.jsp, instantiates an instance of com.example.Product that containsthe results of the form submission?
A. <jsp:useBean id="com.example.Product" />
<jsp:setProperty name="product" property="*" />
B. <jsp:useBean id="product" class="com.example.Product" />
${product.name = param.i1}${product.price = param.i2}
C. <jsp:useBean id="product" class="com.example.Product">
<jsp:setProperty name="product" property="name"param="i1" />
<jsp:setProperty name="product" property="price"param="i2" />
</jsp:useBean>
D. <jsp:useBean id="product" type="com.example.Product">
<jsp:setProperty name="product" property="name"value="<%= request.getParameter( "i1" ) %>" />
<jsp:setProperty name="product" property="price"value="<%= request.getParameter( "i2" ) %>" />
</jsp:useBean>
Answer: C
Question: 21
You need to create a JavaBean object that is used only within the current ISP page. It must NOTbe accessible to any other page including those that this page might import.Which JSP standard action < .in accomplish this goal?
A. <jsp:useBean id = ‘pageBean’ type = ‘com.example.MyBean’ />
B. <jsp:useBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
C. <jsp:makeBean id = ‘pageBean’ type = ‘com.example.MyBean’ />
D. <jsp:makeBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
E. <jsp:useBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
F. <jsp:makeBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
Answer: B
Question : 22
Given the JavaBean class:
public class MyBean {
private Boolean roasted = false;
public MyBean () {}
public Boolean isRoasted ()
{
returned roasted
}
public void setRoasted (Boolean roasted) {
this.roasted = roasted; ]
}
Assume a controller has created an instance of this bean, called setRoasted (true), and insertedthe bean into the application scope using the name “myBean”.
A JSP contains these two tags:
<jsp: useBean id = “aBean” class = “MyBean” scope = “page” \ />
<jsp: getProprty name = “aBean” property = “roasted” \ />Which is true?
A. the page will include the output false
B. the page will include the output
C. the page will report that the property roasted does not exist
D. the page will report that the syntax of the useBean tag is incorrect
E. the page will report that the syntax of the getProperty tag ls incorrect
Answer: E
Reference:http://www.emacao.gov.mo/documents/18/06/exam.pdf(4th table from the top)
Question: 23
A developer chooses to avoid using singieThreadModel but wants to ensure that data If; updatedin a thread safe manner.Which two can support this design goal? (Choose two)
A. Store the data in a local variable.
B. Store the data in an instance variable.
C. Store the data in the Httpsession object.
D. Store the data in the sarvletContext object.
E. Store the data in the ServletRequest object.
Answer: A,E
Question: 24
You have a use in your web application that adds several session-scoped attributes. At the end ofthe use case, one of these objects, the manage attribute, is removed and then it needs to decidewhich of the other session-scoped attributes to remove.
How can this goal be accomplished?
A. The object of the manager attribute should implement the HttpSessionBindingListener and itshould call the removeAttribute method on the appropriate session attributes.
B. The object of the manager attribute should implement the HttpSessionListenar and it should callthe removeAttribute method on the appropriate session attributes.
C. The object of the manager attribute should implement the HttpSessionBindingListener rind itshould call the deleteAttribute method on the appropriate session attributes.
D. The object of the manager attribute should implement the HttpsessionListener and it should callthe deleteAttribute method on the appropriate session attributes.
Answer: A
Question: 25
The Squeaky Beans Inc. shopping application was initially developed for a non-distributedenvironment. The company recently purchased the Acme Application Server, which supportsdistributed Httpsession objects. When deploying the application to the server, the doployer marksit as distributable in the web application deployment descriptor to take advantage of this feature.Given this scenario, which two must be true? (Choose two)
A. The J2EE web container must support migration of objects that implement serializable.
B. The J2EE web container must use the native JVM Serialization mechanism for distributingHttpSesaion objects.
C. As per the specification, the J2EE web container ensures that distributed Httpsassion objectswill be stored in a database.
D. Storing references to Enterprise JavaBeans components in the HttpSession object might NOTsupported by J2EE web contain.
Answer: A,D
Question: 26
Given an HttpServletRequest request and an httpServletResponse response:
41. HttpSession session = null;
42. // insert code here
43. if (session = = null) {
44. // do something if session does not exist
45. } else {
46. // do something if session exists
47. }
To implement the design intent, which statement must be inserted at line 42?
A. session = response.getSession ();
B. session = request.getSession ();
C. session = request.getSession (true);
D. session = request.getSession (false);
E. session = request.getSession (“jsessionid”);
Answer: D
Question: 27
Users of your web application have requested that they should be able to set the duration of theirsessions. So for example, one user might want a webapp to stay connected for an hour ratherthan the webapp's default of fifteen minutes; another user might want to stay connected for awhole day.Furthermore, you have a special login servlet that performs user authentication and retrieves theobject from the database. You want to augment this code to set up the user's specified sessionduration.Which code snippet in the login servlet will accomplish this goal?
A. User user = //retrieves the user objects object from the database
session.setDurationInterval (user.getSessionDuration());
B. User user = / / retrieves the User objects from the database
session.setInactiveInterval (user.getSessionDuration());
C. User user = / / retrieves the user objects object from the database
session.setInactiveInterval (user.get.SessionDuration());
D. User user = / / retrieves the user objects object from the database
session.setDuration (user.getSessionDuration());
E. User user = / / retrieves the user objects object from the database
session.setMaxInactiveInterval (user.getSessionDuration());
F. User user = / / retrieves the user objects object from the database
session.setMaxDurationInterval (user.getSessionDuration());
Answer: E
Question: 28
Which interface must a class implement so that instances of the class are notified after any objectadded to a session?
A. javax.servlet.http.HttpSessionListener
B. javax.servlet.http.HttpSessionValueListener
C. javax.servlet.http.HttpSessionBindingListener
D. javax.servlet.http.HttpSessionAttributeListener
Answer: D
Question: 29
Which statement is true about web container session management?
A. Access to session-scoped attributes is guaranteed to be thread-safe by the web container.
B. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewritingmethod.
C. If the web application uses HTTPS, then the web container may use the data on the HTTPSrequest stream to identify the client.
D. The JSESSIONID cookie is stored permanently on the client so that a user may return to theweb application and the web container will rejoin that session.
Answer: C
Question: 30
A method call inside your servlet has thrown an IOException resulting from a lost networkconnection to a necessary resource. The servlet has determined that it will be unable to operatesuccessfully fen few minutes, but expects to be able to resume operation after that period. Howshould this situation handled?
A. The servlet should re-throw the exception to the web container.
B. The servlet should throw a servletException to the web container.
C. The servlet should throw an unavailableException to the web container.
D. The servlet should redirect to an error page that reports the exception message.
E. The servlet should retry the request until the method returns successfully.
Answer: C
Reference:
http://jcp.org/aboutJava/communityprocess/first/jsr053/servlet23_PFD.pdf(page 26,topic: 2.3.3.2, first paragraph)
Question: 31
During initialization, a servlet finds that the database connection it requires is unavailable. As thesystem designer, you know that the database start up completes several minutes after the web-container initializes the servlet. How should this be handled?
A. Retry the connection until it is successful, then allow the init () method to complete.
B. Throw a ServletException
C. Throw the IOException
D. Throw an UnavailableException
Answer: D
Reference:http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets6.html
Question: 32
A servlet wishes to indicate that it is unable to initialize at the present time, but that the initializationmight succeed at some future time. Which is true?
A. This cannot be expressed. A servlet either initializes correctly or fails.
B. This expression is not necessary. If a servlet fails to initialize, the container will try again latereach time a request is received that attempts to invoke that servlet.
C. The servlet should delay until it is ready to complete initialization successfully.
D. The servlet should throw an UnavailableException
E. The servlet should throw a servletException
Answer: E
Question: 33
You are implementing a model component. You realize that an IOException might arise if you loseconnection to the database. How should you address this?
A. Implement multipathing to provide redundant connectivity to the database, thereby avoiding thatrisk of connection failure.
B. Provide an error handler page, and use the page directive in the invoking ISP to redirect to thatpage if the error arises.
C. Use the JSTL <c:catch> tag to take control if the exception arises.
D. Surround the problem area with a try/catch block and implement appropriate recovery orfallback behavior.
Answer: C
Reference:http://www.ibm.com/developerworks/java/library/j-jstl0318/(topic: exception handling)
Question: 34
Which is a valid value for the enum EmptyRoleSemantic in Javax.servlet.annotation.ServletSecurity?
A.ADMIT
B. PERMIT
C. EXCLUDE
D. DENYALL
E. ALLOWALL
Answer: B
Reference:http://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/annotation/ServletSecurity.EmptyRoleSemantic.html
Question: 35
Given the annotation for MyServlet:@WebServlet{"/abc")
@ServletSecurity (value=@HttpConstraint)public class Myservlet extends Httpservlet {Which two are true? (Choose two)
A. No protection of user data must be performed by the transport.
B. All user data must be encrypted by the transport.
C. Access is to be denied independent of authentication state and identity.
D. Only authenticated users are to be permitted.
E. Access is to be permitted independent of authentication state and identity.
Answer: B,C
Question: 36
Which of the following annotations relate to security in a servlet?
(i) @WebSecurity
(ii) @RolesAllowed
(iii) @WebConstraint
(iv) @HttpConstraint(v) @Servletsecurity
A. (i) only
B. (i) and (iii)
C. (iv) and (v)
D. (iii) and (v)
E. (ii) and (iv)
Answer: C
Question: 37
Which element of a web application deployment descriptor <web-resource-collection> element is used to specify a HTTP method to which the corresponding <security-constraint> will not apply?
A. <exclude-http-method>
B. <neglect-http-method>
C. <http-method-omission>
D. <http-method-excluded>
E. <exceptional-http-method>
Answer: C
Reference:
http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd(search http-method-omission
Question: 38
Which two statements are true about the security-related tags in a valid Java EE deploymentdescriptor? (Choose two)
A. Every <security-constraint> tag must have at least one <http-method> tag.
B. A <security-constraint> tag can have many <web-resource-collection> tags.
C. A given <auth-constraint> tag can apply to only one <web-resource-collection> tag.
D. A given <web-resource-collection> tag can contain from zero to many <url-pattern> tags.
E. It is possible to construct a valid <security-constraint> tag such that, for a given resource userroles can access that resource.
Answer: B,E
Question: 39
A cookie may be set to be an HttpOnly cookie. Setting a cookie to be HttpOnly results in (Choosetwo)
A. Client to not expose the cookie to client side scripting code
B. Does not work with https protocol
C. prevent certain types of cross-site scripting attacks
D. There is no such thing as an HttpOnly cookie
Answer: A,C
Reference:http://docs.oracle.com/javaee/6/api/javax/servlet/http/Cookie.html
Question: 40
A popular Ajax framework and its companion widget library contain several hundreds of files ofdifferent types (.js, .ess, .html). Your company has mandated that all its web applications use onlyspecific versions of this framework approved by IT and repackaged internally as jar files.Furthermore, web applications should only include the entire jar, without subsetting ormodification.Where should the framework's files be placed inside a jar file to enable this kind of reuse?
A. under resources
B. under META-INF/resources
C. under META-INF/web-contents
D. under WEB-INF/resources
Answer: B
Reference:http://ocpsoft.com/opensource/create-common-facelets-jar/(check the box with theupdate)
Question: 41
Which two actions protect a resource file from direct HTTP access within a web application?(Choose two)
A. placing it in the /secure directory
B. placing it in the /WEB-INF directory
C. placing it in the /META-INF/secure directory
D. creating a <web-resource> element within the deployment descriptor
E. creating a <secure-resource> element within the deployment descriptor
Answer: B,C
Question: 42
In which two locations can library dependencies be defined for a web application? (Choose two)
A. the web application deployment descriptor
B. the /META-INF/dependencies.xml file
C. the /META-INF/MANIFEST.MF manifest file
D. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath
Answer: C,D
Question: 43
The jquery_1_3_2.jar file contains the JQuery Ajax framework in its META-INF/ resourcesdirectory. Where should the jar file be placed inside the web application to ensure the resources itcontains are accessible by clients?
A. WEB-INF/classes
B. WEB-INF/jar
C. WEB-INF/lib
D. WEB INF/resources
Answer: C
Reference:http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html(topic: web modules, third paragraph)
Question: 44
Given a jar file packaged with three web fragments with names X, Y and Z respectively.Which of the following deployment descriptor, web.xml, snippets correspond to the web fragmentprocessing orders of X, Y, Z?
(i) <absolute-ordering>
<name>X</name><name>Y</name>
<name>Z</name>
</absolute-ordering>
(ii) <absolute-ordering>
<name>X</name><name>Y</name>
</absolute-ordering>
(iii) <absolute-ordering></others>
<name>Y</name><name>Z</name>
</absolute-ordering>
(iv) <absolute-ordering>
<name>X</name></others>
<name>Z</name>
</absolute-ordering>
(v) <absolute-ordering>
<name>X</name>
<name>Y</name>
</others></absolute-ordering>
A. (i) only
B. (i) and (ii)
C. (i) and (iv)
D. (i), (iii), (iv) and (v)
Answer: C
Reference:http://blogs.oracle.com/swchan/entry/servlet_3_0_web_fragment
Source:
http://examcertifyblog.blogspot.hk/2013/07/1z0-899-e-books.html
http://www.scribd.com/doc/115744012/Best-Oracle-1Z0-899-Exam-Questions-for-FREE
http://www.scribd.com/doc/108002815/OCEJWCD-6-test
</jsp:useBean>
Answer: B,D
Question: 20
Click the Exhibit button.Given the HTML form:
1. <html>
2. <body>
3. <form action="submit.jsp">
4. Name: <input type="text" name="i1"><br>
5. Price: <input type="text" name="i2"><br>
6. <input type="submit">
7. </form>
8. </body>
9. </html>
Assume the product attribute does NOT yet exist in any scope.
Which code snippet, in submit.jsp, instantiates an instance of com.example.Product that containsthe results of the form submission?
A. <jsp:useBean id="com.example.Product" />
<jsp:setProperty name="product" property="*" />
B. <jsp:useBean id="product" class="com.example.Product" />
${product.name = param.i1}${product.price = param.i2}
C. <jsp:useBean id="product" class="com.example.Product">
<jsp:setProperty name="product" property="name"param="i1" />
<jsp:setProperty name="product" property="price"param="i2" />
</jsp:useBean>
D. <jsp:useBean id="product" type="com.example.Product">
<jsp:setProperty name="product" property="name"value="<%= request.getParameter( "i1" ) %>" />
<jsp:setProperty name="product" property="price"value="<%= request.getParameter( "i2" ) %>" />
</jsp:useBean>
Answer: C
Question: 21
You need to create a JavaBean object that is used only within the current ISP page. It must NOTbe accessible to any other page including those that this page might import.Which JSP standard action < .in accomplish this goal?
A. <jsp:useBean id = ‘pageBean’ type = ‘com.example.MyBean’ />
B. <jsp:useBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
C. <jsp:makeBean id = ‘pageBean’ type = ‘com.example.MyBean’ />
D. <jsp:makeBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
E. <jsp:useBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
F. <jsp:makeBean id = ‘pageBean’ class = ‘com.example.MyBean’ />
Answer: B
Question : 22
Given the JavaBean class:
public class MyBean {
private Boolean roasted = false;
public MyBean () {}
public Boolean isRoasted ()
{
returned roasted
}
public void setRoasted (Boolean roasted) {
this.roasted = roasted; ]
}
Assume a controller has created an instance of this bean, called setRoasted (true), and insertedthe bean into the application scope using the name “myBean”.
A JSP contains these two tags:
<jsp: useBean id = “aBean” class = “MyBean” scope = “page” \ />
<jsp: getProprty name = “aBean” property = “roasted” \ />Which is true?
A. the page will include the output false
B. the page will include the output
C. the page will report that the property roasted does not exist
D. the page will report that the syntax of the useBean tag is incorrect
E. the page will report that the syntax of the getProperty tag ls incorrect
Answer: E
Reference:http://www.emacao.gov.mo/documents/18/06/exam.pdf(4th table from the top)
Question: 23
A developer chooses to avoid using singieThreadModel but wants to ensure that data If; updatedin a thread safe manner.Which two can support this design goal? (Choose two)
A. Store the data in a local variable.
B. Store the data in an instance variable.
C. Store the data in the Httpsession object.
D. Store the data in the sarvletContext object.
E. Store the data in the ServletRequest object.
Answer: A,E
Question: 24
You have a use in your web application that adds several session-scoped attributes. At the end ofthe use case, one of these objects, the manage attribute, is removed and then it needs to decidewhich of the other session-scoped attributes to remove.
How can this goal be accomplished?
A. The object of the manager attribute should implement the HttpSessionBindingListener and itshould call the removeAttribute method on the appropriate session attributes.
B. The object of the manager attribute should implement the HttpSessionListenar and it should callthe removeAttribute method on the appropriate session attributes.
C. The object of the manager attribute should implement the HttpSessionBindingListener rind itshould call the deleteAttribute method on the appropriate session attributes.
D. The object of the manager attribute should implement the HttpsessionListener and it should callthe deleteAttribute method on the appropriate session attributes.
Answer: A
Question: 25
The Squeaky Beans Inc. shopping application was initially developed for a non-distributedenvironment. The company recently purchased the Acme Application Server, which supportsdistributed Httpsession objects. When deploying the application to the server, the doployer marksit as distributable in the web application deployment descriptor to take advantage of this feature.Given this scenario, which two must be true? (Choose two)
A. The J2EE web container must support migration of objects that implement serializable.
B. The J2EE web container must use the native JVM Serialization mechanism for distributingHttpSesaion objects.
C. As per the specification, the J2EE web container ensures that distributed Httpsassion objectswill be stored in a database.
D. Storing references to Enterprise JavaBeans components in the HttpSession object might NOTsupported by J2EE web contain.
Answer: A,D
Question: 26
Given an HttpServletRequest request and an httpServletResponse response:
41. HttpSession session = null;
42. // insert code here
43. if (session = = null) {
44. // do something if session does not exist
45. } else {
46. // do something if session exists
47. }
To implement the design intent, which statement must be inserted at line 42?
A. session = response.getSession ();
B. session = request.getSession ();
C. session = request.getSession (true);
D. session = request.getSession (false);
E. session = request.getSession (“jsessionid”);
Answer: D
Question: 27
Users of your web application have requested that they should be able to set the duration of theirsessions. So for example, one user might want a webapp to stay connected for an hour ratherthan the webapp's default of fifteen minutes; another user might want to stay connected for awhole day.Furthermore, you have a special login servlet that performs user authentication and retrieves theobject from the database. You want to augment this code to set up the user's specified sessionduration.Which code snippet in the login servlet will accomplish this goal?
A. User user = //retrieves the user objects object from the database
session.setDurationInterval (user.getSessionDuration());
B. User user = / / retrieves the User objects from the database
session.setInactiveInterval (user.getSessionDuration());
C. User user = / / retrieves the user objects object from the database
session.setInactiveInterval (user.get.SessionDuration());
D. User user = / / retrieves the user objects object from the database
session.setDuration (user.getSessionDuration());
E. User user = / / retrieves the user objects object from the database
session.setMaxInactiveInterval (user.getSessionDuration());
F. User user = / / retrieves the user objects object from the database
session.setMaxDurationInterval (user.getSessionDuration());
Answer: E
Question: 28
Which interface must a class implement so that instances of the class are notified after any objectadded to a session?
A. javax.servlet.http.HttpSessionListener
B. javax.servlet.http.HttpSessionValueListener
C. javax.servlet.http.HttpSessionBindingListener
D. javax.servlet.http.HttpSessionAttributeListener
Answer: D
Question: 29
Which statement is true about web container session management?
A. Access to session-scoped attributes is guaranteed to be thread-safe by the web container.
B. To activate URL rewriting, the developer must use the HttpServletResponse.setURLRewritingmethod.
C. If the web application uses HTTPS, then the web container may use the data on the HTTPSrequest stream to identify the client.
D. The JSESSIONID cookie is stored permanently on the client so that a user may return to theweb application and the web container will rejoin that session.
Answer: C
Question: 30
A method call inside your servlet has thrown an IOException resulting from a lost networkconnection to a necessary resource. The servlet has determined that it will be unable to operatesuccessfully fen few minutes, but expects to be able to resume operation after that period. Howshould this situation handled?
A. The servlet should re-throw the exception to the web container.
B. The servlet should throw a servletException to the web container.
C. The servlet should throw an unavailableException to the web container.
D. The servlet should redirect to an error page that reports the exception message.
E. The servlet should retry the request until the method returns successfully.
Answer: C
Reference:
http://jcp.org/aboutJava/communityprocess/first/jsr053/servlet23_PFD.pdf(page 26,topic: 2.3.3.2, first paragraph)
Question: 31
During initialization, a servlet finds that the database connection it requires is unavailable. As thesystem designer, you know that the database start up completes several minutes after the web-container initializes the servlet. How should this be handled?
A. Retry the connection until it is successful, then allow the init () method to complete.
B. Throw a ServletException
C. Throw the IOException
D. Throw an UnavailableException
Answer: D
Reference:http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets6.html
Question: 32
A servlet wishes to indicate that it is unable to initialize at the present time, but that the initializationmight succeed at some future time. Which is true?
A. This cannot be expressed. A servlet either initializes correctly or fails.
B. This expression is not necessary. If a servlet fails to initialize, the container will try again latereach time a request is received that attempts to invoke that servlet.
C. The servlet should delay until it is ready to complete initialization successfully.
D. The servlet should throw an UnavailableException
E. The servlet should throw a servletException
Answer: E
Question: 33
You are implementing a model component. You realize that an IOException might arise if you loseconnection to the database. How should you address this?
A. Implement multipathing to provide redundant connectivity to the database, thereby avoiding thatrisk of connection failure.
B. Provide an error handler page, and use the page directive in the invoking ISP to redirect to thatpage if the error arises.
C. Use the JSTL <c:catch> tag to take control if the exception arises.
D. Surround the problem area with a try/catch block and implement appropriate recovery orfallback behavior.
Answer: C
Reference:http://www.ibm.com/developerworks/java/library/j-jstl0318/(topic: exception handling)
Question: 34
Which is a valid value for the enum EmptyRoleSemantic in Javax.servlet.annotation.ServletSecurity?
A.ADMIT
B. PERMIT
C. EXCLUDE
D. DENYALL
E. ALLOWALL
Answer: B
Reference:http://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/annotation/ServletSecurity.EmptyRoleSemantic.html
Question: 35
Given the annotation for MyServlet:@WebServlet{"/abc")
@ServletSecurity (value=@HttpConstraint)public class Myservlet extends Httpservlet {Which two are true? (Choose two)
A. No protection of user data must be performed by the transport.
B. All user data must be encrypted by the transport.
C. Access is to be denied independent of authentication state and identity.
D. Only authenticated users are to be permitted.
E. Access is to be permitted independent of authentication state and identity.
Answer: B,C
Question: 36
Which of the following annotations relate to security in a servlet?
(i) @WebSecurity
(ii) @RolesAllowed
(iii) @WebConstraint
(iv) @HttpConstraint(v) @Servletsecurity
A. (i) only
B. (i) and (iii)
C. (iv) and (v)
D. (iii) and (v)
E. (ii) and (iv)
Answer: C
Question: 37
Which element of a web application deployment descriptor <web-resource-collection> element is used to specify a HTTP method to which the corresponding <security-constraint> will not apply?
A. <exclude-http-method>
B. <neglect-http-method>
C. <http-method-omission>
D. <http-method-excluded>
E. <exceptional-http-method>
Answer: C
Reference:
http://java.sun.com/xml/ns/javaee/web-common_3_0.xsd(search http-method-omission
Question: 38
Which two statements are true about the security-related tags in a valid Java EE deploymentdescriptor? (Choose two)
A. Every <security-constraint> tag must have at least one <http-method> tag.
B. A <security-constraint> tag can have many <web-resource-collection> tags.
C. A given <auth-constraint> tag can apply to only one <web-resource-collection> tag.
D. A given <web-resource-collection> tag can contain from zero to many <url-pattern> tags.
E. It is possible to construct a valid <security-constraint> tag such that, for a given resource userroles can access that resource.
Answer: B,E
Question: 39
A cookie may be set to be an HttpOnly cookie. Setting a cookie to be HttpOnly results in (Choosetwo)
A. Client to not expose the cookie to client side scripting code
B. Does not work with https protocol
C. prevent certain types of cross-site scripting attacks
D. There is no such thing as an HttpOnly cookie
Answer: A,C
Reference:http://docs.oracle.com/javaee/6/api/javax/servlet/http/Cookie.html
Question: 40
A popular Ajax framework and its companion widget library contain several hundreds of files ofdifferent types (.js, .ess, .html). Your company has mandated that all its web applications use onlyspecific versions of this framework approved by IT and repackaged internally as jar files.Furthermore, web applications should only include the entire jar, without subsetting ormodification.Where should the framework's files be placed inside a jar file to enable this kind of reuse?
A. under resources
B. under META-INF/resources
C. under META-INF/web-contents
D. under WEB-INF/resources
Answer: B
Reference:http://ocpsoft.com/opensource/create-common-facelets-jar/(check the box with theupdate)
Question: 41
Which two actions protect a resource file from direct HTTP access within a web application?(Choose two)
A. placing it in the /secure directory
B. placing it in the /WEB-INF directory
C. placing it in the /META-INF/secure directory
D. creating a <web-resource> element within the deployment descriptor
E. creating a <secure-resource> element within the deployment descriptor
Answer: B,C
Question: 42
In which two locations can library dependencies be defined for a web application? (Choose two)
A. the web application deployment descriptor
B. the /META-INF/dependencies.xml file
C. the /META-INF/MANIFEST.MF manifest file
D. the /META-INF/MANIFEST.MF manifest of a JAR in the web application classpath
Answer: C,D
Question: 43
The jquery_1_3_2.jar file contains the JQuery Ajax framework in its META-INF/ resourcesdirectory. Where should the jar file be placed inside the web application to ensure the resources itcontains are accessible by clients?
A. WEB-INF/classes
B. WEB-INF/jar
C. WEB-INF/lib
D. WEB INF/resources
Answer: C
Reference:http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html(topic: web modules, third paragraph)
Question: 44
Given a jar file packaged with three web fragments with names X, Y and Z respectively.Which of the following deployment descriptor, web.xml, snippets correspond to the web fragmentprocessing orders of X, Y, Z?
(i) <absolute-ordering>
<name>X</name><name>Y</name>
<name>Z</name>
</absolute-ordering>
(ii) <absolute-ordering>
<name>X</name><name>Y</name>
</absolute-ordering>
(iii) <absolute-ordering></others>
<name>Y</name><name>Z</name>
</absolute-ordering>
(iv) <absolute-ordering>
<name>X</name></others>
<name>Z</name>
</absolute-ordering>
(v) <absolute-ordering>
<name>X</name>
<name>Y</name>
</others></absolute-ordering>
A. (i) only
B. (i) and (ii)
C. (i) and (iv)
D. (i), (iii), (iv) and (v)
Answer: C
Reference:http://blogs.oracle.com/swchan/entry/servlet_3_0_web_fragment
Explanation:
Reference:
http://www.softwareengineeringsolutions.com/blogs/2010/08/01/ (3rd paragraph)
Source:
http://examcertifyblog.blogspot.hk/2013/07/1z0-899-e-books.html
http://www.scribd.com/doc/115744012/Best-Oracle-1Z0-899-Exam-Questions-for-FREE
http://www.scribd.com/doc/108002815/OCEJWCD-6-test
No comments:
Post a Comment