1Z0-858 - Java Enterprise Edition 5 Web Component Developer Certified Professional Exam

Go back to Oracle

Example Questions

Your management has required that all JSPs be created to generate XHTML-compliant content and to facilitate that decision, you are required to create all JSPs using the JSP Document format. In the reviewOrder.jspx page, you need to use several core JSTL tags to process the collection of order items in the customer's shopping cart. Which JSP code snippets must you use in the reviewOrder.jspx page? Which two classes or interfaces provide a getSession method? (Choose two.) Given: 10. public void service(ServletRequest request, 11. ServletResponse response) { 12. ServletInputStream sis = 13. // insert code here 14. } Which retrieves the binary input stream on line 13? Which two about WAR files are true? (Choose two.) 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.) In a JSP-centric web application, you need to create a catalog browsing JSP page. The catalog is stored as a List object in the catalog attribute of the webapp's ServletContext object. Which scriptlet code snippet gives you access to the catalog object? You are building a Front Controller using a JSP page and you need to determine if the user's session has NOT been created yet and perform some special processing for this case. Which scriptlet code snippet will perform this test? Given: 3. public class MyTagHandler extends TagSupport { 4. public int doStartTag() { 5. // insert code here 6. // return an int 7. } 8. // more code here ... 18. } There is a single attribute foo in the session scope. Which three code fragments, inserted independently at line 5, return the value of the attribute? (Choose three.) A developer has created a special servlet that is responsible for generating XML content that is sent to a data warehousing subsystem. This subsystem uses HTTP to request these large data files, which are compressed by the servlet to save internal network bandwidth. The developer has received a request from management to create several more of these data warehousing servlets. The developer is about to copy and paste the compression code into each new servlet. Which design pattern can consolidate this compression code to be used by all of the data warehousing servlets? 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? Which JSTL code snippet produces the output "big number" when X is greater than 42, but outputs "small number" in all other cases? You have created a servlet that generates weather maps. The data for these maps is calculated by a remote host. The IP address of this host is usually stable, but occasionally does have to change as the corporate network grows and changes. This IP address used to be hard coded, but after the fifth change to the IP address in two years, you have decided that this value should be declared in the deployment descriptor so you do NOT have the recompile the web application every time the IP address changes. Which deployment descriptor snippet accomplishes this goal? The sl:shoppingList and sl:item tags output a shopping list to the response and are used as follows: <sl:shoppingList> <sl:item name=”Bread” /> <sl:item name=”Milk” /> <sl:item name=”Eggs” /> </sl:shoppingList> The tag handler for sl:shoppingList is ShoppingListTag and the tag handler for sl:item is ItemSimpleTag. ShoppingListTag extends BodyTagSupport and ItemSimpleTag extends SimpleTagSupport. Which is true? 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.) Which two are true about authentication? (Choose two.) What is true about Java EE authentication mechanisms? For a given ServletResponse response, which two retrieve an object for writing text data? (Choose two) For debugging purposes, you need to record how many times a given JSP is invoked before the user's session has been created. The JSP's destroy method stores this information to a database. Which JSP code snippet keeps track of this count for the lifetime of the JSP page? Which two actions protect a resource file from direct HTTP access within a web application?(Choose two.) Which JSTL code snippet can be used to import content from another web resource? 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? In your web application, you need to execute a block of code whenever the session object is first created. Which design will accomplish this goal? You need to create a JSP that generates some JavaScript code to populate an array of strings used on the client-side. Which JSP code snippet will create this array? What is the purpose of session management? 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.) Which is true about the web container request processing model? You are creating a content management system (CMS) with a web application front-end. The JSP that displays a given document in the CMS has the following general structure: 1<%-- tag declaration --%> 2. <t:document> ... 11. <t:paragraph>... <t:citation docID='xyz' /> ...</t:paragraph> ... 99. </t:document> The citation tag must store information in the document tag for the document tag to generate a reference section at the end of the generated web page. The document tag handler follows the Classic tag model and the citation tag handler follows the Simple tag model. Furthermore, the citation tag could also be embedded in other custom tags that could have either the Classic or Simple tag handler model. Which tag handler method allows the citation tag to access the document tag? You are creating a JSP page to display a collection of data. This data can be displayed in several different ways so the architect on your project decided to create a generic servlet that generates acomma-delimited string so that various pages can render the data in different ways. This servlet takes on request parameter: objectID. Assume that this servlet is mapped to the URL pattern:/WEB-INF/data.In the JSP you are creating, you need to split this string into its elements separated by commas and generate an HTML <ul> list from the data. Which JSTL code snippet will accomplish this goal? For manageability purposes, you have been told to add a "count" instance variable to a critical JSP Document so that a JMX MBean can track how frequent this JSP is being invoked. Which JSP code snippet must you use to declare this instance variable in the JSP Document? 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: private static final Set<String> USE_CASE_ATTRS; static { USE_CASE_ATTRS.add("customerOID"); USE_CASE_ATTRS.add("custMgrBean"); USE_CASE_ATTRS.add("orderOID"); USE_CASE_ATTRS.add("orderMgrBean"); } Which code snippet deletes these attributes from the session object? Your web page includes a Java SE v1.5 applet with the following declaration: 11. <object classid='clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA' 12. width='200' height='200'> 13. <param name='code' value='Applet.class' /> 14. </object> Which HTTP method is used to retrieve the applet code? Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the message "File not found." An error page has been configured for this JSP page. Which option prevents the exception thrown by my:errorProne from invoking the error page mechanism, and outputs the message "File not found" in the response? A developer is designing a web application that must verify for each request: The originating request is from a trusted network. The client has a valid session. The client has been authenticated. Which design pattern provides a solution in this situation? You want to create a filter for your web application and your filter will implement javax.servlet.Filter. Which two statements are true? (Choose two.) You are creating a new JSP page and you need to execute some code that acts when the page is first executed, but only once. Which three are possible mechanisms for performing this initialization code? (Choose three.) Assume that a news tag library contains the tags lookup and item: lookup Retrieves the latest news headlines and executes the tag body once for each headline. Exposes a NESTED page-scoped attribute called headline of type com.example.Headline containing details for that headline. item Outputs the HTML for a single news headline. Accepts an attribute info of type com.example.Headline containing details for the headline to be rendered. Which snippet of JSP code returns the latest news headlines in an HTML table, one per row? 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 by the servlet to the JSP; furthermore, that JSP uses a custom tag and must also process this information. This information must NOT be accessible to any other servlet, JSP or session in the webapp. How can you accomplish this goal? You are creating a web form with this HTML: 11. <form action="sendOrder.jsp"> 12. <input type="text" name="creditCard"> 13. <input type="text" name="expirationDate"> 14. <input type="submit"> 15. </form> Which HTTP method is used when sending this request from the browser? Your web site has many user-customizable features, for example font and color preferences on web pages. Your IT department has already built a subsystem for user preferences using Java SE's lang.util.prefs package APIs and you have been ordered to reuse this subsystem in your web application. You need to create an event listener that stores the user's Preference object when an HTTP session is created. Also, note that user identification information is stored in an HTTP cookie. Which partial listener class can accomplish this goal? Given that a web application consists of two HttpServlet classes, ServletA and ServletB, and the ServletA.service method: 20. String key = "com.example.data"; 21. session.setAttribute(key, "Hello"); 22. Object value = session.getAttribute(key); 23. Assume session is an HttpSession, and is not referenced anywhere else in ServletA. Which two changes, taken together, ensure that value is equal to "Hello" on line 23? (Choose two.) Given the JSP code : <%request.setAttribute("foo","bar");%> And the classic tag handler code : Public int doStartTag() throws JspException{ //insert code here //return int } Assume there are no other “foo” attributes in the web application. Which invocation on the pageContext object, inserted at line 6(//insert code here), assigns “bar” to the variable x? Given a header in an HTTP request: X-Retries: 4 Which two retrieve the value of the header from a given HttpServletRequest request? (Choose two.) Which two JSTL URL-related tags perform URL rewriting? (Choose two.) 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? Given in a single JSP page: <%@ taglib prefix='java' uri='myTags' %> <%@ taglib prefix='JAVA' uri='moreTags' %> Which two are true? (Choose two.) You have a new IT manager that has mandated that all JSPs must be refactored to include no scritplet code. The IT manager has asked you to enforce this. Which deployment descriptor element will satisfy this constraint? 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? 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.) Which activity supports the data integrity requirements of an application? The JSP developer wants a comment to be visible in the final output to the browser. Which comment style needs to be used in a JSP page?