Wednesday, February 4, 2015

SCWCD Questions And Answers Part 7

Q: 181 Your web application uses a simple architecture in which servlets handle requests and then forward to a JSP using a request dispatcher. You need to pass information calculated in the servlet to the JSP for view generation. This information must NOT be accessible to any other servlet, JSP or session in the webapp. Which two techniques can you use to accomplish this goal? (Choose two.)

A. Add attributes to the session object.
B. Add attributes on the request object.
C. Add parameters to the request object.
D. Use the pageContext object to add request attributes.
E. Add parameters to the JSP's URL when generating the request dispatcher.

Answer: B, E

Q: 182 For which three events can web application event listeners be registered? (Choose three.)

A. when a session is created
B. after a servlet is destroyed
C. when a session has timed out
D. when a cookie has been created
E. when a servlet has forwarded a request
F. when a session attribute value is changed

Answer: A, C, F

Q: 183 Given: 

String value = getServletContext().getInitParameter("foo");
in an HttpServlet and a web application deployment descriptor that contains: 

<context-param> <param-name>foo</param-name> <param-value>frodo</param-value>
</context-param>

Which two are true? (Choose two.)


A. The foo initialization parameter CANNOT be set programmatically.
B. Compilation fails because getInitParameter returns type Object.
C. The foo initialization parameter is NOT a servlet initialization parameter.
D. Compilation fails because ServletContext does NOT have a getInitParameter method.
E. The foo parameter must be defined within the <servlet> element of the deployment descriptor.
F. The foo initialization parameter can also be retrieved using getServletConfig().getInitParameter("foo").

Answer: A, C

Q: 184 Click the Exhibit button. Given the web application deployment descriptor elements:

11. <filter>
12. <filter-name>ParamAdder</filter-name>
13. <filter-class>com.example.ParamAdder</filter-class>
14. </filter>
...
31. <filter-mapping>
32. <filter-name>ParamAdder</filter-name>
33. <servlet-name>Destination</servlet-name>
34. </filter-mapping>
...
55. <servlet-mapping>
56. <servlet-name>Destination</servlet-name>
57. <url-pattern>/dest/Destination</url-pattern>
58. </servlet-mapping>

What is the result of a client request of the Source servlet with no query string?


A. The output "filterAdded = null" is written to the response stream.
B. The output "filterAdded = addedByFilter" is written to the response stream.
C. An exception is thrown at runtime within the service method of the Source servlet.
D. An exception is thrown at runtime within the service method of the Destination servlet.

Answer: A

Q: 185 Given a Filter class definition with this method: 

21. public void doFilter(ServletRequest request,
22. ServletResponse response,
23. FilterChain chain)
24. throws ServletException, IOException {
25. // insert code here
26. }

Which should you insert at line 25 to properly invoke the next filter in the chain, or the target servlet if there are no more filters?


A. chain.forward(request, response);
B. chain.doFilter(request, response);
C. request.forward(request, response);
D. request.doFilter(request, response);

Answer: B

Q: 186 Servlet A forwarded a request to servlet B using the forward method of RequestDispatcher. What attribute in B's request object contains the URI of the original request received by servlet A?

A. REQUEST_URI
B. javax.servlet.forward.request_uri
C. javax.servlet.forward.REQUEST_URI
D. javax.servlet.request_dispatcher.request_uri
E. javax.servlet.request_dispatcher.REQUEST_URI

Answer: B


Q: 187 You want to create a valid directory structure for your Java EE web application, and you want to put your web application into a WAR file called MyApp.war. Which two are true about the WAR file? (Choose two.)

A. At deploy time, Java EE containers add a directory called META-INF directly into the MyApp directory.
B. At deploy time, Java EE containers add a file called MANIFEST.MF directly into the MyApp directory.
C. It can instruct your Java EE container to verify, at deploy time, whether you have properly configured your application's classes.
D. At deploy time, Java EE containers add a directory call META-WAR directly into the MyApp directory.

Answer: A, C

Q: 188 Which two from the web application deployment descriptor are valid? (Choose two.)


A. <error-page> <exception-type>*</exception-type> <location>/error.html</location> </error-page>
B. <error-page> <exception-type>java.lang.Error</exception-type> <location>/error.html</location>
</error-page>
C. <error-page>
<exception-type>java.lang.Throwable</exception-type> <location>/error.html</location>
</error-page> 
D. <error-page>
<exception-type>java.io.IOException</exception-type> <location>/error.html</location>
</error-page> 
E. <error-page>
<exception-type>NullPointerException</exception-type> <location>/error.html</location>
</error-page>

Answer: C, D

Q: 189 After a merger with another small business, your company has inherited a legacy WAR file but the original source files were lost. After reading the documentation of that web application, you discover that the WAR file contains a useful tag library that you want to reuse in your own webapp packaged as a WAR file.

What do you need to do to reuse this tag library?


A. Simply rename the legacy WAR file as a JAR file and place it in your webapp's library directory.
B. Unpack the legacy WAR file, move the TLD file to the META-INF directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.
C. Unpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the whole thing as a JAR file, and place that JAR file in your webapp's library directory.
DUnpack the legacy WAR file, move the TLD file to the META-INF directory, move the class files to the top-level directory, repackage the WAR, and place that WAR file in your webapp's WEB-INF directory. 

Answer: C

Q: 190 Which path is required to be present within a WAR file?

A. /classes
B. /index.html
C. /MANIFEST-INF
D. /WEB-INF/web.xml
E. /WEB-INF/classes
F. /WEB-INF/index.html
G. /META-INF/index.xml

Answer: D

Q: 191 Given:


11. <servlet>
12. <servlet-name>catalog</servlet-name>
13. <jsp-file>/catalogTemplate.jsp</jsp-file>
14. <load-on-startup>10</load-on-startup>
15. </servlet>

Which two are true? (Choose two.)


A. Line 13 is not valid for a servlet declaration.
B. Line 14 is not valid for a servlet declaration.
C. One instance of the servlet will be loaded at startup.
D. Ten instances of the servlet will be loaded at startup.
E. The servlet will be referenced by the name catalog in mappings.

Answer: C, E

Q: 192 You have built a web application with tight security. Several directories of your webapp are used for internal purposes and you have overridden the default servlet to send an HTTP 403 status code for any request that maps to one of these directories. During testing, the Quality Assurance director decided that they did NOT like seeing the bare response page generated by Firefox and Internet Explorer. The director recommended that the webapp should return a more user-friendly web page that has the same look-and-feel as the webapp plus links to the webapp's search engine. You have created this JSP page in the /WEB-INF/jsps/error403.jsp file. You do NOT want to alter the complex logic of the default servlet. How can you declare that the web container must send this JSP page whenever a 403 status is generated?

A. <error-page> <error-code>403</error-code> <url>/WEB-INF/jsps/error403.jsp</url> </error-page>
B. <error-page> <status-code>403</status-code> <url>/WEB-INF/jsps/error403.jsp</url> </error-page>
C. <error-page> <error-code>403</error-code>
<location>/WEB-INF/jsps/error403.jsp</location> </error-page>
D. <error-page> <status-code>403</status-code> <location>/WEB-INF/jsps/error403.jsp</location> </error-page>

Answer: C

Q: 193 Given a portion of a valid Java EE web application's directory structure:

MyApp
|
|-- Directory1
|    |-- File1.html
|
|-- META-INF
| |-- File2.html
|
|-- WEB-INF
|--       File3.html

You want to know whether File1.html, File2.html, and/or File3.html is protected from direct access by your web client's browsers.What statement is true?


A. All three files are directly accessible.
B. Only File1.html is directly accessible.
C. Only File2.html is directly accessible.
D. Only File3.html is directly accessible.
E. Only File1.html and File2.html are directly accessible.
F. Only File1.html and File3.html are directly accessible.
G. Only File2.html and File3.html are directly accessible.

Answer: B

Q: 194 A web component accesses a local EJB session bean with a component interface of com.example.Account with a home interface of com.example.AccountHome and a JNDI reference of ejb/Account. Which makes the local EJB component accessible to the web components in the web application deployment descriptor?

A. <env-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</env-ref>
B. <resource-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</resource-ref>
C. <ejb-local-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local>
</ejb-local-ref>
D. <ejb-remote-ref> <ejb-ref-name>ejb/Account</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.example.AccountHome</local-home> <local>com.example.Account</local> </ejb-remote-ref>

Answer: C

Q: 195 One of the use cases in your web application uses many session-scoped attributes. At the end of the use case, you want to clear out this set of attributes from the session object. Assume that this static variable holds this set of attribute names:

201. private static final Set<String> USE_CASE_ATTRS;
202. static {
203. USE_CASE_ATTRS.add("customerOID");
204. USE_CASE_ATTRS.add("custMgrBean");
205. USE_CASE_ATTRS.add("orderOID");
206. USE_CASE_ATTRS.add("orderMgrBean");
207. }

Which code snippet deletes these attributes from the session object?


A. session.removeAll(USE_CASE_ATTRS);
B. for ( String attr : USE_CASE_ATTRS ) { session.remove(attr);
}
C. for ( String attr : USE_CASE_ATTRS ) { session.removeAttribute(attr);
}
D. for ( String attr : USE_CASE_ATTRS ) { session.deleteAttribute(attr);
}
E. session.deleteAllAttributes(USE_CASE_ATTRS);

Answer: C 

Q: 196 Given an HttpServletRequest request:
22. String id = request.getParameter("jsessionid");
23. // insert code here
24. String name = (String) session.getAttribute("name");

Which three can be placed at line 23 to retrieve an existing HttpSession object? (Choose three.
)

A. HttpSession session = request.getSession();
B. HttpSession session = request.getSession(id);
C. HttpSession session = request.getSession(true);
D. HttpSession session = request.getSession(false);
E. HttpSession session = request.getSession("jsessionid");

Answer: A, C, D

Q: 197 A developer for the company web site has been told that users may turn off cookie support in their browsers. What must the developer do to ensure that these customers can still use the web application?


A. The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIs.
B. The developer must provide an alternate mechanism for managing sessions and abandon the HttpSession mechanism entirely.
C. The developer can ignore this issue. Web containers are required to support automatic URL rewriting when cookies are not supported.
D. The developer must add the string ?id=<sessionid> to the end of every URL to ensure that the conversation with the browser can continue.

Answer: A

Q: 198 You need to store a floating point number, called Tsquare, in the session scope. Which two code snippets allow you to retrieve this value? (Choose two.)


A. float Tsquare = session.getFloatAttribute("Tsquare");
B. float Tsquare = (Float) session.getAttribute("Tsquare");
C. float Tsquare = (float) session.getNumericAttribute("Tsquare");
D. float Tsquare = ((Float) session.getAttribute.("Tsquare")).floatValue();
E. float Tsquare = ((Float) session.getFloatAttribute.("Tsquare")).floatValue;
F. float Tsquare = ((Float) session.getNumericAttribute.("Tsquare")).floatValue;

Answer: B, D

Q: 199 Given the definition of MyObject and that an instance of MyObject is bound as a session attribute:


8. package com.example;
9. public class MyObject implements
10. javax.servlet.http.HttpSessionBindingListener {
11. // class body code here
12. }

Which is true?

A. Only a single instance of MyObject may exist within a session.
B. The unbound method of the MyObject instance is called when the session to which it is bound times out.
C. The com.example.MyObject must be declared as a servlet event listener in the web application deployment descriptor.
D. The valueUnbound method of the MyObject instance is called when the session to which it is bound times out.

Answer: D

 Q: 200 As a convenience feature, your web pages include an Ajax request every five minutes to a special servlet that monitors the age of the user's session. The client-side JavaScript that handles the Ajax callback displays a message on the screen as the session ages. The Ajax call does NOT pass any cookies, but it passes the session ID in a request parameter called sessionID. In addition, assume that your webapp keeps a hashmap of session objects by the ID. Here is a partial implementation of this servlet:

10. public class SessionAgeServlet extends HttpServlet {
11. public void service(HttpServletRequest request, HttpServletResponse) throws IOException {
12. String sessionID = request.getParameter("sessionID");
13. HttpSession session = getSession(sessionID);
14. long age = // your code here
15. response.getWriter().print(age);
16. }
... // more code here 47. }

Which code snippet on line 14, will determine the age of the session?


A. session.getMaxInactiveInterval();
B. session.getLastAccessed().getTime() - session.getCreationTime().getTime();
C. session.getLastAccessedTime().getTime() - session.getCreationTime().getTime();
D. session.getLastAccessed() - session.getCreationTime();
E. session.getMaxInactiveInterval() - session.getCreationTime();
F. session.getLastAccessedTime() - session.getCreationTime();

Answer: F

Q: 201 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.setURLRewriting method.
C. If the web application uses HTTPS, then the web container may use the data on the HTTPS request stream to identify the client.
D. 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.

Answer: C

Q: 202 You are designing an n-tier Java EE application. You have already decided that some of your JSPs will need to get data from a Customer entity bean. You are trying to decide whether to use a Customer stub object or a Transfer Object. Which two statements are true? (Choose two.)

A. The stub will increase network traffic.
B. The Transfer Object will decrease data staleness.
C. The stub will increase the logic necessary in the JSPs.
D. In both cases, the JSPs can use EL expressions to get data.
E. Only the Transfer Object will need to use a Business Delegate.
F. Using the stub approach allows you to design the application without using a Service Locator.

Answer: A, D

Q: 203 Which two are characteristics of the Intercepting Filter pattern? (Choose two.)

A. It provides centralized request handling for incoming requests.
B. It forces resource authentication to be distributed across web components.
C. It reduces coupling between presentation-tier clients and underlying business services.
D. It can be added and removed unobtrusively, without requiring changes to existing code.
E. It allows preprocessing and postprocessing on the incoming requests and outgoing responses.

Answer: D, E

Q: 204 A developer has created a web application that includes a servlet for each use case in the application. These servlets have become rather difficult to maintain because the request processing methods have become very large. There is also common processing code in many servlets because these use cases are very similar. Which two design patterns can be used together to refactor and simplify this web application? (Choose two.)


A. Proxy
B. View Helper
C. F ront Controller
D. Session Facade
E. Business Delegate
F. Model-View-Controller

Answer: C, F 

Q: 205 A developer is designing a multi-tier web application and discovers a need to hide the details of establishing and maintaining remote communications from the client. In addition, the application needs to find, in a transparent manner, the heterogeneous business components used to service the client's requests. Which design patterns, working together, address these issues?


A. Business Delegate and Transfer Object
B. Business Delegate and Service Locator
C. Front Controller and Business Delegate
D. Intercepting Filter and Transfer Object
E. Model-View-Controller and Intercepting Filter

Answer: B 

Q: 206 A developer is designing a web application that must support multiple interfaces, including:


an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem?


A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility

Answer: D 

Q: 207 A developer is designing a web application which extensively uses EJBs and JMS. The developer finds that there is a lot of duplicated code to build the JNDI contexts to access the beans and queues. Further, because of the complexity, there are numerous errors in the code. Which J2EE design pattern provides a solution for this problem?

A. Command
B. Transfer Object
C. Service Locator
D. Session Facade
E. Business Delegate
F. Data Access Object

Answer: C

Q: 208 A developer is designing a web application that must support multiple interfaces, including: 

an XML web service for B2B HTML for web-based clients WML for wireless customers
Which design pattern provides a solution for this problem? 


A. Session Facade
B. Business Delegate
C. Data Access Object
D. Model-View-Controller
E. Chain of Responsibility

Answer: D

Q: 209 Which two are characteristics of the Front Controller pattern? (Choose two.)


A. It simplifies remote interfaces to distributed objects.
B. It promotes cleaner application partitioning and encourages reuse.
C. It provides an initial point of contact for handling all related requests.
D. It reduces maintainability due to the increased complexity of the design.
E. It provides loosely coupled handlers that can be combined in various permutations.

Answer: B, C

Q: 210 Squeaky Beans Inc. hired an outside consultant to develop their web application. To finish the job quickly, the consultant created several dozen JSP pages that directly communicate with the database. The Squeaky business team has since purchased a set of business objects to model their system, and the Squeaky developer charged with maintaining the web application must now refactor all the JSPs to work with the new system. Which pattern can the developer use to solve this problem?

A. Transfer Object
B. Service Locator
C. Intercepting Filter
D. Business Delegate

Answer: D

Sunday, January 11, 2015

SCJP Sun Certified Programmer for Java 6 Study Guide: Exam 310-065 



Description


SCJP Sun Certified Programmer for Java 6 Study Guide covers what you need to know--and shows you how to prepare--for this challenging exam.
100% complete coverage of all official objectives for exam 310-065
Exam Objective Highlights in every chapter point out certification objectives to ensure you're focused on passing the exam Exam Watch sections in every chapter highlight key exam topics covered Simulated exam questions match the format, tone, topics, and difficulty of the real exam.




Book details


  • Publisher: McGraw Hill Education
  • By: Kathy Sierra, Bert Bates
  • ISBN: 978-0071591065
  • Year: 2008
  • Pages: 851 pages
  • Language: English
  • Size: 2.95 MB
  • File Format: PDF

eBook

     



Oracle Certified Professional Java SE7 Programmer Exams 1Z0-804 and 1Z0-805: A Comprehensive OCPJP 7 Certification Guide: A Comprehensive OCPJP 7 Certification Guide 



Description


Oracle Certified Professional Java SE7 Programmer Exams 1Z0-804 and 1Z0-805: a Comprehensive OCPJP 7 Certification Guide is a book of aspirants who wish to take the Oracle Certified Professional Java SE7 Programmer Exams. It contains in-depth details and explanations of the 13 topic syllabus.






Book details


  • Publisher: APress
  • By: S.G.Ganesh, Tushar Sharma
  • ISBN: 978-1430247647
  • Year: 2013
  • Pages: 656 pages
  • Language: English
  • Size: 5.73 MB
  • File Format: PDF

eBook

     



OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804)



Description


OCA/OCP Java SE 7 Programmer I and II exams with this exclusive Oracle Press guide. Chapters feature challenging exercises, a certification summary, a two-minute drill, and a self-test to reinforce the topics presented. This authoritative resource helps you pass these exams and also serves as an essential, on-the-job reference.
Oracle Certified Professional Java SE7 Programmer Exams 1Z0-804 and 1Z0-805: a Comprehensive OCPJP 7 Certification Guide is a book that makes sure you have an all round preparation for the relevant examinations. 


Book details


  • Publisher: McGraw Hill Education
  • By: Kathy Sierra, Bert Bates
  • ISBN: 978-0071772006
  • Year: 2014
  • Pages: 888 pages
  • Language: English
  • Size: 6.73 MB
  • File Format: PDF

eBook

     



Scwcd Exam Study Kit: Java Web Component Developer Certification



Description


Java developers, Servlet/JSP developers, and J2EE developers pass the Sun Certified Web Component Developer Exam (SCWCD 310-081), this study guide covers all aspects of the Servlet and JSP technology that Sun has determined necessary. This new edition adds aspects of servlet/JSP development, such as the Expression language, and updated materials of servlets with a particular focus on using filters to make request processing more efficient. Covering the reliance on the JSP Standard Template Library (JSTL) and its core, this guide allows JSP developers will be able to simplify their development process and remove Java-based scriptlets and expressions from their code. All applications in this book are designed to run on Apache's latest development server, Tomcat 5.0, and instructions on how to install this new edition and execute servlets and JSPs are included.


Book details


  • Publisher: Manning Publications
  • By: Hanumant Deshmukh, Jignesh Malavia, Matthew Scarpino
  • ISBN: 978-1932394382
  • Year: 2005
  • Pages: 531 pages
  • Language: English
  • Size: 4.53 MB
  • File Format: PDF

eBook

     

Saturday, January 10, 2015

Java EE 5 Certification






Exam Topics


Section 1: The Servlet Technology Model
  • For each of the HTTP Methods (such as GET, POST, HEAD, and so on) describe the purpose of the method and the technical characteristics of the HTTP Method protocol, list triggers that might cause a Client (usually a Web browser) to use the method; and identify the HttpServlet method that corresponds to the HTTP Method.
  • Using the HttpServletRequest interface, write code to retrieve HTML form parameters from the request, retrieve HTTP request header information, or retrieve cookies from the request.
  • Using the HttpServletResponse interface, write code to set an HTTP response header, set the content type of the response, acquire a text stream for the response, acquire a binary stream for the response, redirect an HTTP request to another URL, or add cookies to the response.
  • Describe the purpose and event sequence of the servlet life cycle: (1) servlet class loading, (2) servlet instantiation, (3) call the init method, (4) call the service method, and (5) call destroy method.
Section 2: The Structure and Deployment of Web Applications
  • Construct the file and directory structure of a Web Application that may contain (a) static content, (b) JSP pages, (c) servlet classes, (d) the deployment descriptor, (e) tag libraries, (d) JAR files, and (e) Java class files; and describe how to protect resource files from HTTP access.
  • Describe the purpose and semantics of the deployment descriptor.
  • Construct the correct structure of the deployment descriptor.
  • Explain the purpose of a WAR file and describe the contents of a WAR file, how one may be constructed.
Section 3: The Web Container Model
  • For the ServletContext initialization parameters: write servlet code to access initialization parameters; and create the deployment descriptor elements for declaring initialization parameters.
  • For the fundamental servlet attribute scopes (request, session, and context): write servlet code to add, retrieve, and remove attributes; given a usage scenario, identify the proper scope for an attribute; and identify multi-threading issues associated with each scope.
  • Describe the Web container request processing model; write and configure a filter; create a request or response wrapper; and given a design problem, describe how to apply a filter or a wrapper.
  • Describe the Web container life cycle event model for requests, sessions, and web applications;create and configure listener classes for each scope life cycle; create and configure scope attribute listener classes; and given a scenario, identify the proper attribute listener to use.
  • Describe the RequestDispatcher mechanism; write servlet code to create a request dispatcher; write servlet code to forward or include the target resource; and identify and describe the additional request-scoped attributes provided by the container to the target resource.
Section 4: Session Management
  • Write servlet code to store objects into a session object and retrieve objects from a session object.
  • Given a scenario describe the APIs used to access the session object, explain when the session object was created, and describe the mechanisms used to destroy the session object, and when it was destroyed.
  • Using session listeners, write code to respond to an event when an object is added to a session, and write code to respond to an event when a session object migrates from one VM to another.
  • Given a scenario, describe which session management mechanism the Web container could employ, how cookies might be used to manage sessions, how URL rewriting might be used to manage sessions, and write servlet code to perform URL rewriting.
Section 5: Web Application Security
  • Based on the servlet specification, compare and contrast the following security mechanisms: (a) authentication, (b) authorization, (c) data integrity, and (d) confidentiality.
  • In the deployment descriptor, declare a security constraint, a Web resource, the transport guarantee, the login configuration, and a security role.
  • Compare and contrast the authentication types (BASIC, DIGEST, FORM, and CLIENT-CERT); describe how the type works; and given a scenario, select an appropriate type.
Section 6: The JavaServer Pages (JSP) Technology Model
  • Identify, describe, or write the JSP code for the following elements: (a) template text, (b) scripting elements (comments, directives, declarations, scriptlets, and expressions), (c) standard and custom actions, and (d) expression language elements.
  • Write JSP code that uses the directives: (a) 'page' (with attributes 'import', 'session', 'contentType', and 'isELIgnored'), (b) 'include', and (c) 'taglib'.
  • Write a JSP Document (XML-based document) that uses the correct syntax.
  • Describe the purpose and event sequence of the JSP page life cycle: (1) JSP page translation, (2) JSP page compilation, (3) load class, (4) create instance, (5) call the jspInit method, (6) call the _jspService method, and (7) call the jspDestroy method.
  • Given a design goal, write JSP code using the appropriate implicit objects: (a) request, (b) response, (c) out, (d) session, (e) config, (f) application, (g) page, (h) pageContext, and (i) exception.
  • Configure the deployment descriptor to declare one or more tag libraries, deactivate the evaluation language, and deactivate the scripting language. 6.7 Given a specific design goal for including a JSP segment in another page, write the JSP code that uses the most appropriate inclusion mechanism (the include directive or the jsp:include standard action).
Section 7: Building JSP Pages Using the Expression Language (EL)
  • Given a scenario, write EL code that accesses the following implicit variables including pageScope, requestScope, sessionScope, and applicationScope, param and paramValues, header and headerValues, cookie, initParam and pageContext.
  • Given a scenario, write EL code that uses the following operators: property access (the . operator), collection access (the [] operator).
Section 8: Building JSP Pages Using Standard Actions
  • Given a design goal, create a code snippet using the following standard actions: jsp:useBean (with attributes: 'id', 'scope', 'type', and 'class'), jsp:getProperty, jsp:setProperty (with all attribute combinations), and jsp:attribute.
  • Given a design goal, create a code snippet using the following standard actions: jsp:include, jsp:forward, and jsp:param.
Section 9: Building JSP Pages Using Tag Libraries
  • For a custom tag library or a library of Tag Files, create the 'taglib' directive for a JSP page.
  • Given a design goal, create the custom tag structure in a JSP page to support that goal.
  • Given a design goal, use an appropriate JSP Standard Tag Library (JSTL v1.1) tag from the "core" tag library.
Section 10: Building a Custom Tag Library
  • Describe the semantics of the "Classic" custom tag event model when each event method (doStartTag, doAfterBody, and doEndTag) is executed, and explain what the return value for each event method means; and write a tag handler class.
  • Using the PageContext API, write tag handler code to access the JSP implicit variables and access web application attributes.
  • Given a scenario, write tag handler code to access the parent tag and an arbitrary tag ancestor.
  • Describe the semantics of the "Simple" custom tag event model when the event method (doTag) is executed; write a tag handler class; and explain the constraints on the JSP content within the tag.
  • Describe the semantics of the Tag File model; describe the web application structure for tag files; write a tag file; and explain the constraints on the JSP content in the body of the tag.
Section 11: Java EE Patterns
  • Given a scenario description with a list of issues, select a pattern that would solve the issues. The list of patterns you must know are: Intercepting Filter, Model-View-Controller, Front Controller, Service Locator, Business Delegate, and Transfer Object.
  • Match design patterns with statements describing potential benefits that accrue from the use of the pattern, for any of the following patterns: Intercepting Filter, Model-View-Controller, Front Controller, Service Locator, Business Delegate, and Transfer Object.

Java SE 6 Certification






Exam Topics


Section 1: Declarations, Initialization and Scoping
  • Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and import statements (including static imports).
  • Develop code that declares an interface. Develop code that implements or extends one or more interfaces.
  • Develop code that declares an abstract class. Develop code that extends an abstract class.
  • Develop code that declares, initializes, and uses primitives, arrays, enums, and objects as static, instance, and local variables. Also, use legal identifiers for variable names.
  • Given a code example, determine if a method is correctly overriding or overloading another method, and identify legal return values (including covariant returns), for the method.
  • Given a set of classes and superclasses, develop constructors for one or more of the classes. Given a class declaration, determine if a default constructor will be created, and if so, determine the behavior of that constructor. Given a nested or non-nested class listing, write code to instantiate the class.
Section 2: Flow Control
  • Develop code that implements an if or switch statement; and identify legal argument types for these statements.
  • Develop code that implements all forms of loops and iterators, including the use of for, the enhanced for loop (for-each), do, while, labels, break, and continue; and explain the values taken by loop counter variables during and after loop execution.
  • Develop code that makes use of assertions, and distinguish appropriate from inappropriate uses of assertions.
  • Develop code that makes use of exceptions and exception handling clauses (try, catch, finally), and declares methods and overriding methods that throw exceptions.
  • Recognize the effect of an exception arising at a specified point in a code fragment. Note that the exception may be a runtime exception, a checked exception, or an error.
  • Recognize situations that will result in any of the following being thrown: ArrayIndexOutOfBoundsException,ClassCastException, IllegalArgumentException, IllegalStateException, NullPointerException, NumberFormatException, AssertionError, ExceptionInInitializerError, StackOverflowError or NoClassDefFoundError. Understand which of these are thrown by the virtual machine and recognize situations in which others should be thrown programatically.
Section 3: API Contents
  • Develop code that uses the primitive wrapper classes (such as Boolean, Character, Double, Integer, etc.), and/or autoboxing & unboxing. Discuss the differences between the String, StringBuilder, and StringBuffer classes.
  • Given a scenario involving navigating file systems, reading from files, writing to files, or interacting with the user, develop the correct solution using the following classes (sometimes in combination), from java.io: BufferedReader, BufferedWriter, File, FileReader, FileWriter, PrintWriter, and Console.
  • Use standard J2SE APIs in the java.text package to correctly format or parse dates, numbers, and currency values for a specific locale; and, given a scenario, determine the appropriate methods to use if you want to use the default locale or a specific locale. Describe the purpose and use of the java.util.Locale class.
  • Write code that uses standard J2SE APIs in the java.util and java.util.regex packages to format or parse strings or streams. For strings, write code that uses the Pattern and Matcher classes and the String.split method. Recognize and use regular expression patterns for matching (limited to: . (dot), * (star), + (plus), ?, \d, \s, \w, [], ()). The use of *, +, and ? will be limited to greedy quantifiers, and the parenthesis operator will only be used as a grouping mechanism, not for capturing content during matching. For streams, write code using the Formatter and Scanner classes and the PrintWriter.format/printf methods. Recognize and use formatting parameters (limited to: %b, %c, %d, %f, %s) in format strings.
Section 4: Concurrency
  • Write code to define, instantiate, and start new threads using both java.lang.Thread and java.lang.Runnable.
  • Recognize the states in which a thread can exist, and identify ways in which a thread can transition from one state to another.
  • Given a scenario, write code that makes appropriate use of object locking to protect static or instance variables from concurrent access problems.
Section 5: OO Concepts
  • Develop code that implements tight encapsulation, loose coupling, and high cohesion in classes, and describe the benefits.
  • Given a scenario, develop code that demonstrates the use of polymorphism. Further, determine when casting will be necessary and recognize compiler vs. runtime errors related to object reference casting.
  • Explain the effect of modifiers on inheritance with respect to constructors, instance or static variables, and instance or static methods.
  • Given a scenario, develop code that declares and/or invokes overridden or overloaded methods and code that declares and/or invokes superclass, or overloaded constructors.
  • Develop code that implements "is-a" and/or "has-a" relationships.
Section 6: Collections / Generics
  • Given a design scenario, determine which collection classes and/or interfaces should be used to properly implement that design, including the use of the Comparable interface.
  • Distinguish between correct and incorrect overrides of corresponding hashCode and equals methods, and explain the difference between == and the equals method.
  • Write code that uses the generic versions of the Collections API, in particular, the Set, List, and Map interfaces and implementation classes. Recognize the limitations of the non-generic Collections API and how to refactor code to use the generic versions. Write code that uses the NavigableSet and NavigableMap interfaces.
  • Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches.
  • Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang.String on sorting.
Section 7: Fundamentals
  • Given a code example and a scenario, write code that uses the appropriate access modifiers, package declarations, and import statements to interact with (through access or inheritance) the code in the example.
  • Given an example of a class and a command-line, determine the expected runtime behavior.
  • Determine the effect upon object references and primitive values when they are passed into methods that perform assignments or other modifying operations on the parameters.
  • Given a code example, recognize the point at which an object becomes eligible for garbage collection, determine what is and is not guaranteed by the garbage collection system, and recognize the behaviors of the Object.finalize() method.
  • Given the fully-qualified name of a class that is deployed inside and/or outside a JAR file, construct the appropriate directory structure for that class. Given a code example and a classpath, determine whether the classpath will allow the code to compile successfully.
  • Write code that correctly applies the appropriate operators including assignment operators (limited to: =, +=, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --), relational operators (limited to: <, <=, >, >=, ==, !=), the instanceof operator, logical operators (limited to: &, |, ^, !, &&, ||), and the conditional operator ( ? : ), to produce a desired result. Write code that determines the equality of two objects or two primitives.

WHAT IS OCJP?


     Oracle Certified Java Programmer or OCJP certification is a dignified recognition for an individual possessing the knowledge of java programming. Popular by name Sun Certified Java Programmer or SCJP, the OCJP certification has got its name as Oracle Corporation took over Sun Microsystems. The Java certifications that were earlier called with the name of Sun started being called with the name of Oracle.

IMPORTANCE OF CERTIFICATION:  


  •    OCJP certification is meant for the Java programmers and hence is very useful for an individual having sound knowledge of the programming concepts. 
  •    Certification can play a valuable role during the initial career phase of an individual when he/she is seeking to enter the IT field for becoming a programmer/developer. This will be a credit for a programmer and thereby will increase his/her chances to be recognized by the employers for better job opportunities. 
  •    Certification will prove the worth of an individual as a person with good knowhow of development concepts using this web development language. Hence, as a fresher looking for job as a programmer, one should definitely try for OCJP certification exam.

WHAT IS OCWCD?


     The Oracle Certified Web Component Developer (OCWCD 5.0) for J2EE Platform certification exam. Popular by name Sun Certified Web Component Developer or SCWCD, the OCWCD certification has got its name as Oracle Corporation took over Sun Microsystems. Oracle Certified Programmers who are using the Java technology servlet and JavaServer Pages (JSP) application program interface (APIs) to develop Web applications. Prior to beginning the Oracle Certified Web Component Developer program, you must be a Oracle Certified Java Programmer(OCJP) for the Java platform (any edition).

IMPORTANCE OF CERTIFICATION: 


  •    OCWCD 5.0 certification proves your expertise on the Oracle Java products and technologies. Professionals holding the OCWCD certification are preferred by the employers and they also get preference in promotions. 
  •    OCWCD certification is helpful for professionals who want to upgrade their credentials and get recognition from the IT industry. 
  •    OCWCD certification proves your expertise on the Oracle Java web components and technologies to get paid more.

Wednesday, January 7, 2015

SCWCD Questions And Answers Part 6

Q: 151 Click the Task button.


Place the code snippets in the proper order to construct the JSP code to include dynamic content into a JSP page at request-time.


Answer: Check ExamWorx eEngine, Download from Member Center


Q: 152 Given:

6.  <% int[] nums = {42, 420, 4200};

7.        request.setAttribute("foo", nums); %>

Which two successfully translate and result in a value of true? (Choose two.)

A. ${true or false}
B. ${requestScope[foo][0] > 500}
C. ${requestScope['foo'][1] = 420}
D. ${(requestScope['foo'][0] lt 50) && (3 gt 2)}

Answer: A, D


Q: 153 Click the Exhibit button.
Given:

11.  <% com.example.Advisor advisor = new com.example.Advisor(); %>

12.  <% request.setAttribute("foo", advisor); %>
Assuming there are no other "foo" attributes in the web application, which three are valid EL expressions for retrieving the advice property of advisor? (Choose three.)


A. ${foo.advice}
B. ${request.foo.advice}
C. ${requestScope.foo.advice}
D. ${requestScope[foo[advice]]}
E. ${requestScope["foo"]["advice"]}
F. ${requestScope["foo"["advice"]]}
  
Answer: A, C, E


Q: 154 You are creating an error page that provides a user-friendly screen whenever a server exception occurs. You want to hide the stack trace, but you do want to provide the exception's error message to the user so the user can provide it to the customer service agent at your company. Which EL code snippet inserts this error message into the error page?

A. Message: <b>${exception.message}</b> 
B. Message: <b>${exception.errorMessage}</b>
C. M essage: <b>${request.exception.message}</b>
D. Message: <b>${pageContext.exception.message}</b>
E. Message: <b>${request.exception.errorMessage}</b>
F. Message: <b>${pageContext.exception.errorMessage}</b> 

Answer: D


Q: 155 You are building a dating web site. The client's date of birth is collected along with lots of other information. You have created an EL function with the signature: calcAge(java.util.Date):int and it is assigned to the name, age, in the namespace, funct. In one of your JSPs you need to print a special message to clients who are younger than 25. Which EL code snippet will return true for this condition?

A. ${calcAge(client.birthDate) < 25}
B. ${calcAge[client.birthDate] < 25}
C. ${funct:age(client.birthDate) < 25}
D. ${funct:age[client.birthDate] < 25}
E. ${funct:calcAge(client.birthDate) < 25}
F. ${funct:calcAge[client.birthDate] < 25} 

Answer: C


Q: 156 Given:

11.  <% java.util.Map map = new java.util.HashMap();

12.        request.setAttribute("map", map);
13.        map.put("a", "b");
14.        map.put("b", "c");
15.        map.put("c", "d"); %>
16.  <%-- insert code here --%>

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


Q: 157 Assume the tag handler for a st:simple tag extends SimpleTagSupport. In what way can scriptlet code be used in the body of st:simple? 

A.      set the body content type to JSP in the TLD

B.      Scriptlet code is NOT legal in the body of st:simple.
C.      add scripting-enabled="true" to the start tag for the st:simple element
D.      add a pass-through Classic tag with a body content type of JSP to the body of st:simple, and place the scriptlet code in the body of that tag

Answer: B

www.ExamWorx.com Q: 158 Which statement is true if the doStartTag method returns EVAL_BODY_BUFFERED ? 

A.      The tag handler must implement BodyTag.

B.      The doAfterBody method is NOT called.
C.      The setBodyContent method is called once.
D.      It is never legal to return EVAL_BODY_BUFFERED from doStartTag. 

Answer: C


Q: 159 You are creating a library of custom tags that mimic the HTML form tags. When the user submits a form that fails validation, the JSP form is forwarded back to the user. The <t:textField> tag must support the ability to re-populate the form field with the request parameters from the user's last request. For example, if the user entered "Samantha" in the text field called firstName, then the form is re-populated like this:

<input type='text' name='firstName' value='Samantha' />

Which tag handler method will accomplish this goal?

A. public int doStartTag() throws JspException { JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name); if ( value == null ) value = "";
JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); } return SKIP_BODY;
}
private static String INPUT
= "<input type='text' name='%s' value='%s' />"; B. public void doTag() throws JspException { JspContext ctx = getJspContext();
String value = ctx.getParameter(this.name); if ( value == null ) value = "";
JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";
C. public int doStartTag() throws JspException { ServletRequet request = pageContext.getRequest(); String value = request.getParameter(this.name);
if ( value == null ) value = ""; JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); } return SKIP_BODY;
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";
D. public void doTag() throws JspException { ServletRequet request = pageContext.getRequest(); String value = request.getParameter(this.name);
if ( value == null ) value = ""; JspWriter out = pageContext.getOut(); try {
out.write(String.format(INPUT, this.name, value)); } (Exception e) { throw new JspException(e); }
}
private static String INPUT = "<input type='text' name='%s' value='%s' />";

Answer: C


Q: 160 Which two directives are applicable only to tag files? (Choose two.)

A. tag
B. page
C. taglib
D. include
E. variable

Answer: A, E


Q: 161 The tl:taskList and tl:task tags output a set of tasks to the response and are used as follows:

11.  <tl:taskList>

12.      <tl:task name="Mow the lawn" />
13.      <tl:task name="Feed the dog" />
14.      <tl:task name="Do the laundry" />
15.  </tl:taskList>

The tl:task tag supplies information about a single task while the tl:taskList tag does the final output. The tag handler for tl:taskList is TaskListTag. The tag handler for tl:task is TaskTag. Both tag handlers extend BodyTagSupport.

Which allows the tl:taskList tag to get the task names from its nested tl:task children?

A. It is impossible for a tag handler that extends BodyTagSupport to communicate with its parent and child tags.
B. In the TaskListTag.doStartTag method, call super.getChildTags() and iterate through the results. Cast each result to a TaskTag and call getName().
C. In the TaskListTag.doStartTag method, call getChildTags() on the PageContext and iterate through the results. Cast each result to a TaskTag and call getName().
D. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return BodyTag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call super.getParent(), cast it to a TaskListTag, and call addTaskName().
E. Create an addTaskName method in TaskListTag. Have the TaskListTag.doStartTag method, return BodyTag.EVAL_BODY_BUFFERED. In the TaskTag.doStartTag method, call findAncestorWithClass() on the PageContext, passing TaskListTag as the class to find. Cast the result to TaskListTag and call addTaskName().

Answer: D


Q: 162 Click the Exhibit button.

Given:

10.  <form action='create_product.jsp'>

11.      Product Name: <input type='text' name='prodName'/><br/>
12.      Product Price: <input type='text' name='prodPrice'/><br/> 
13. </form>

For a given product instance, which three jsp:setProperty attributes must be used to initialize its properties from the HTML form? (Choose three.)



A. id
B. name
C. type
D. param
E. property
F. reqParam
G. attribute
 
Answer: B, D, E


Q: 163 Given:

1. package com.example;

2.
3.  public abstract class AbstractItem {
4.      private String name;
...
13. }

Assume a concrete class com.example.ConcreteItem extends com.example.AbstractItem. A servlet sets a session-scoped attribute called "item" that is an instance of com.example.ConcreteItem and then forwards to a JSP page.

Which two are valid standard action invocations that expose a scripting variable to the JSP page? (Choose two.)

A. <jsp:useBean id="com.example.ConcreteItem" scope="session" />
B. <jsp:useBean id="item" type="com.example.ConcreteItem" scope="session" />
C. <jsp:useBean id="item" class="com.example.ConcreteItem" scope="session" />
D. <jsp:useBean id="item" type="com.example.ConcreteItem" class="com.example.AbstractItem"
scope="session" />

Answer: B, C


Q: 164 Your web application views all have the same header, which includes the <title> tag in the <head> element of the rendered HTML. You have decided to remove this redundant HTML code from your JSPs and put it into a single JSP called /WEB-INF/jsp/header.jsp. However, the title of each page is unique, so you have decided to use a variable called pageTitle to parameterize this in the header JSP, like this:

10. <title>${param.pageTitle}<title> 
Which JSP code snippet should you use in your main view JSPs to insert the header and pass the pageTitle variable?

A. <jsp:insert page='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:insert>
B. <jsp:include page='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:include>
C. <jsp:include file='/WEB-INF/jsp/header.jsp'> ${pageTitle='Welcome Page'}
</jsp:include>
D. <jsp:insert page='/WEB-INF/jsp/header.jsp'> <jsp:param name='pageTitle' value='Welcome Page' /> </jsp:insert>
E. <jsp:include page='/WEB-INF/jsp/header.jsp'> <jsp:param name='pageTitle' value='Welcome Page' /> </jsp:include> 

Answer: E


Q: 165 Click the Exhibit button.

Given the JSP code:

1.  <%

2.      pageContext.setAttribute( "product",
3.          new com.example.Product( "Pizza", 0.99 ) );
4.  %>
5.  <%-- insert code here --%>

Which two, inserted at line 5, 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


Q: 166 If you want to use the Java EE platform's built-in type of authentication that uses a custom HTML page for authentication, which two statements are true? (Choose two.)

A. Your deployment descriptor will need to contain this tag: <auth-method>CUSTOM</auth-method>. 
B. The related custom HTML login page must be named loginPage.html.
C. When you use this type of authentication, SSL is turned on automatically.
D. You must have a tag in your deployment descriptor that allows you to point to both a login HTML page and an HTML page for handling any login errors.
E. In the HTML related to authentication for this application, you must use predefined variable names for the variables that store the user and password values. 

Answer: D, E


Q: 167 Given the two security constraints in a deployment descriptor:

101.  <security-constraint>

102.      <!--a correct url-pattern and http-method goes here-->
103.      <auth-constraint><role-name>SALES</role-name></auth-
103.      <auth-constraint>
104.          <role-name>SALES</role-name>
105.      </auth-constraint>
106.  </security-constraint>
107.  <security-constraint>
108.      <!--a correct url-pattern and http-method goes here-->
109.      <!-- Insert an auth-constraint here -->
110.  </security-constraint>

If the two security constraints have the same url-pattern and http-method, which two, inserted independently at line 109, will allow users with role names of either SALES or MARKETING to access this resource? (Choose two.)


A. <auth-constraint/>
B. <auth-constraint> <role-name>*</role-name> </auth-constraint>
C. <auth-constraint><role-name>ANY</role-name> </auth-constraint>
D. <auth-constraint> <role-name>MARKETING</role-name> </auth-constraint> 

Answer: B, D


Q: 168 Which two are valid values for the <transport-guarantee> element inside a <security-constraint> element of a web application deployment descriptor? (Choose two.)

A. NULL
B. SECURE
C. INTEGRAL
D. ENCRYPTED
E. CONFIDENTIAL 

Answer: C, E


Q: 169 Which basic authentication type is optional for a J2EE 1.4 compliant web container?

A. HTTP Basic Authentication
B. Form Based Authentication
C. HTTP Digest Authentication
D. HTTPS Client Authentication 

Answer: C


Q: 170 Which security mechanism uses the concept of a realm?

A. authorization
B. data integrity
C. confidentiality
D. authentication 

Answer: D


Q: 171 Which two security mechanisms can be directed through a sub-element of the <user-data-constraint> element in a web application deployment descriptor? (Choose two.)

A. authorization
B. data integrity
C. confidentiality
D. authentication 

Answer: B, C


Q: 172 You are developing several tag libraries that will be sold for development of third-party web applications. You are about to publish the first three libraries as JAR files: container-tags.jar, advanced-html-form-tags.jar, and basic-html-form-tags.jar. Which two techniques are appropriate for packaging the TLD files for these tag libraries? (Choose two.)

A. The TLD must be located within the WEB-INF directory of the JAR file.
B. The TLD must be located within the META-INF directory of the JAR file.
C. The TLD must be located within the META-INF/tld/ directory of the JAR file.
D. The TLD must be located within a subdirectory of WEB-INF directory of the JAR file.
E. The TLD must be located within a subdirectory of META-INF directory of the JAR file.
F. The TLD must be located within a subdirectory of META-INF/tld/ directory of the JAR file. 

Answer: B, E


Q: 173 A custom tag is defined to take three attributes. Which two correctly invoke the tag within a JSP page? (Choose two.)

A. <prefix:myTag a="foo" b="bar" c="baz" />
B. <prefix:myTag attributes={"foo","bar","baz"} />
C. <prefix:myTag jsp:attribute a="foo" b="bar" c="baz" />
D. <prefix:myTag> <jsp:attribute a:foo b:bar c:baz /> </prefix:myTag>
E. <prefix:myTag> <jsp:attribute ${"foo", "bar", "baz"} /> </prefix:myTag>
F. <prefix:myTag> <jsp:attribute a="foo" b="bar" c="baz"/> </prefix:myTag>
G. <prefix:myTag> <jsp:attribute name="a">foo</jsp:attribute>
<jsp:attribute name="b">bar</jsp:attribute> <jsp:attribute name="c">baz</jsp:attribute> </prefix:myTag> 

Answer: A, G


Q: 174 In a JSP-centric shopping cart application, you need to move a client's home address of the Customer object into the shipping address of the Order object. The address data is stored in a value object class called Address with properties for: street address, city, province, country, and postal code. Which two JSP code snippets can be used to accomplish this goal? (Choose two.)

A. <c:set var='order' property='shipAddress' value='${client.homeAddress}' />
B. <c:set target='${order}' property='shipAddress' value='${client.homeAddress}' />
C. <jsp:setProperty name='${order}' property='shipAddress' value='${client.homeAddress}' />
D. <c:set var='order' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:store>
E. <c:set target='${order}' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:set>
F. <c:setProperty name='${order}' property='shipAddress'> <jsp:getProperty name='client' property='homeAddress' /> </c:setProperty>

Answer: B, E


Q: 175 You have been contracted to create a web site for a free dating service. One feature is the ability for one client to send a message to another client, which is displayed in the latter client's private page. Your contract explicitly states that security is a high priority. Therefore, you need to prevent cross-site hacking in which one user inserts JavaScript code that is then rendered and invoked when another user views that content. Which two JSTL code snippets will prevent cross-site hacking in the scenario above? (Choose two.)

20. <c:out>${message}</c:out>
21. <c:out value='${message}' />
22. <c:out value='${message}' escapeXml='true' />
23. <c:out eliminateXml='true'>${message}</c:out>
24. <c:out value='${message}' eliminateXml='true' />
Answer: B, C


Q: 176 Click the Exhibit button.

Assuming the tag library in the exhibit is imported with the prefix forum, which custom tag invocation produces a translation error in a JSP page?


A. <forum:message from="My Name" subject="My Subject" />
B. <forum:message subject="My Subject"> My message body.</forum:message>
C. <forum:message from="My Name" subject="${param.subject}"> ${param.body}
</forum:message>
D. <forum:message from="My Name" subject="My Subject"> <%= request.getParameter( "body" ) %> </forum:message>
E. <forum:message from="My Name" subject="<%= request.getParameter( "subject" ) %>"> My message body. </forum:message> 

Answer: D


Q: 177 Which JSTL code snippet can be used to import content from another web resource?

A. <c:import url="foo.jsp"/>
B. <c:import page="foo.jsp"/>
C. <c:include url="foo.jsp"/>
D. <c:include page="foo.jsp"/>
E. Importing cannot be done in JSTL. A standard action must be used instead. 

Answer: A


Q: 178 Click the Exhibit button.

Assume the tag library in the exhibit is placed in a web application in the path /WEB-INF/tld/example.tld.

1.

2. <ex:hello />

Which JSP code, inserted at line 1, completes the JSP code to invoke the hello tag?


A. <%@ taglib prefix="ex" uri="/WEB-INF/tld" %>
B. <%@ taglib uri="/WEB-INF/tld/example.tld" %>
C. <%@ taglib prefix="ex" uri="http://localhost:8080/tld/example.tld" %>
D. <%@ taglib prefix="ex" uri="http://example.com/tld/example" %> 

Answer: D


Q: 179 Which JSTL code snippet produces the output "big number" when X is greater than 42, but outputs "small number" in all other cases?

A. <c:if test='<%= (X > 42) %>'> <c:then>big number</c:then> <c:else>small number</c:else> </c:if>
B. <c:if> <c:then test='<%= (X > 42) %>'>big number</c:then><c:else>small number</c:else> </c:if>
C. <c:choose test='<%= (X > 42) %>'> <c:then>big number</c:when> <c:else>small number</c:otherwise> </c:choose>
D. <c:choose test='<%= (X > 42) %>'> <c:when>big number</c:when> <c:otherwise>small number</c:otherwise> </c:choose>
E. <c:choose> <c:when test='<%= (X > 42) %>'>big number</c:when> <c:otherwise>small number</c:otherwise> </c:choose>

Answer: E

Q: 180 A developer chooses to avoid using SingleThreadModel but wants to ensure that data is updated in 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 ServletContext object.
E. Store the data in the ServletRequest object.

Answer: A, E