A programmer has a validly configured directory structure for his Java EE web application which is called MyWebApp. In which two directories could a file called myTag.tag
reside in order to be accessed correctly by the container? (Choose two.)
Which of the following are legal EL? (Choose all that apply)
A TLD from a Java forum website contains this tag definition:
<tag> <name>avatar</name> <tag-class>hf.AvatarTagHandler</tag-class> <body-content>empty</body-content> <attribute> <name>userId</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>size</name> <required>false</required> <rtexprvalue>false</rtexprvalue> </attribute> </tag>
What is true about AvatarTagHandler, assuming it extends SimpleTagSupport and outputs HTML that displays a user’s avatar image? (Choose all that apply.)
A. | The class should have a setter method called | |
B. | No size variable is needed in the code because the TLD states it is not required. | |
C. | An overridden | |
D. | An overridden | |
E. | The class must overload all implemented lifecycle methods with a version that includes an extra parameter for every attribute defined in the TLD. In this case there is only one. |
A Servlet sets up a bean before forwarding to a JSP.
Given:
20. foo.User user = new foo.User(); 21. user.setFirst(request.getParameter("firstName")); 22. user.setLast(request.getParameter("lastName")); 23. user.setStreet(request.getParameter("streetAddress")); 24. user.setCity(request.getParameter("city")); 25. user.setState(request.getParameter("state")); 26. user.setZipCode(request.getParameter("zipCode")); 27. request.setAttribute("user", user);
What snippet, if placed in a JSP, could replace the Servlet code above? (Choose all that apply.)
A. |
| |
B. | <jsp:useBean id="user" type="foo.User" scope="request"> <jsp:setProperty name="user" property="*"/> </jsp:useBean> | |
C. | <jsp:useBean id="user" class="foo.User" scope="request"> <jsp:setProperty name="user" property="first" param="firstName"/> <jsp:setProperty name="user" property="last" param="lastName"/> <jsp:setProperty name="user" property="street" param="streetAddress"/> <jsp:setProperty name="user" property="city"/> <jsp:setProperty name="user" property="state"/> <jsp:setProperty name="user" property="zipCode"/> </jsp:useBean> | |
D. | <jsp:useBean id="user" class="foo.User" scope="request"> <jsp:setProperty name="user" property="*"/> <jsp:setProperty name="user" property="first" param="firstName"/> <jsp:setProperty name="user" property="last" param="lastName"/> <jsp:setProperty name="user" property="street" param="streetAddress"/> </jsp:useBean> |
When comparing the benefits, limitations, and uses of a business delegate object and a service locator object, which are true? (Choose all that apply.)
A. | They are equally likely to make network calls. | |
B. | They are equally likely to invoke methods in a transfer object. | |
C. | They are equally likely to be invoked directly from a controller object. | |
D. | The service locator will typically be considered a server to the business delegate. | |
E. | When both are implemented with a cache, data staleness is a bigger issue for the business delegate. |
When creating session listeners which are true? (Choose all that apply.)
A. | They are all declared in the DD. | |
B. | Not all of them must be declared in the DD. | |
C. | The DD tag used to declare them is | |
D. | The DD tag used to declare them is | |
E. | The DD tag used to declare them is placed within the | |
F. | The DD tag used to declare them is placed within the |
Some users have complained that strange things are happening when they have two browser windows open on a single machine and both windows access the application at the same time. You want to test various browsers to see if a session would be shared across multiple windows. You decide to do this by outputting the JSESSIONID
in a JSP. How could you accomplish this, assuming you have cookies enabled on your test browsers? (Choose all that apply.)
Which implicit object can access the attributes from the ServletContext
?
Which methods exist in HttpServlet
? (Choose all that apply.)
You have determined that certain capabilities in your web application will require that users be registered members. In addition, your web application sometimes deals with user data that your users want you to keep confidential.
Which are true? (Choose all that apply.)
A. | You can make transmitted data confidential only after your application has verified the user’s password. | |
B. | Of the various types of authentication guaranteed by a Java EE container, only BASIC, Digest, and Form Based are implemented by matching a user name to a password. | |
C. | No matter what type of Java EE authentication mechanism you use, it will only be activated when an otherwise constrained resource is requested. | |
D. | All of the Java EE guaranteed types of authentication provide strong data security without the need to implement supporting security features. |
Given these fragments from within a single tag in a Java EE DD:
343. <web-resource-collection> 344. <web-resource-name>Recipes</web-resource-name> 345. <url-pattern>/Beer/Update/*</url-pattern> 346. <http-method>POST</http-method> 347. </web-resource-collection> ... 367. <auth-constraint> 368. <role-name>Member</role-name> 369. </auth-constraint> ... 385. <user-data-constraint> 386. <transport-guarantee>CONFIDENTIAL</transport-guarantee> 387. </user-data-constraint>
Which are true? (Choose all that apply.)
A. | A Java EE DD can contain a single tag in which all of these tags can legally co-exist. | |
B. | It is valid for more instances of | |
C. | It is valid for more instances of | |
D. | It is valid for more instances of | |
E. | It is valid for other tags of the same type as the single encasing tag described above to have the same | |
F. | This tag implies that authorization, authentication, and data integrity security features are all declared for the web application. |
You are creating a JSP Document that generates a dynamic SVG image which is represented by an XML document structure. The JSP must declare the HTTP response header 'Content-Type'
as 'image/svg+xml'
so that the web browser will render the response as an SVG image.
Which JSP code snippet declares that this JSP Document is an SVG response?
Given in a JSP page, the line:
<%-- out.print("Hello World"); --%>
What is the HTML output?
Which statements about HTTP session support are true? (Choose all that apply.)
A. | Java EE containers must support HTTP cookies. | |
B. | Java EE containers may support URL rewriting. | |
C. | Java EE containers must support the Secure Sockets Layer. | |
D. | Java EE containers must support HTTP sessions, even for clients that do not support cookies. | |
E. | Java EE containers must recognize the HTTP termination signal that is issued to indicate that a client session is no longer active. |
Your company has purchased a license for a third party JavaScript library for constructing menus. Your team has run into countless errors by mistakingly misusing the library and the users are insisting that certain menu items should only be visible to users with the authorized security role. A custom tag library using Simple tag handlers could shield developers from making syntactical JavaScript errors and provide the security features the users desire.
After a design meeting, your team lead documented that she would like the menu to look like the following:
<menu:main> <menu:headItem text="My Account" url="/myAccount.do"/> <menu:headItem text="Transactions"> <menu:subItem text="Incoming" url="/incomingTx.do"/> <menu:subItem text="Outgoing" url="/outgoingTx.do"/> <menu:subItem text="Pending" url="/pendingTx.do" requireRole="accountant"/> </menu:headItem> <menu:headItem text="Admin" url="/admin.do" requireRole="admin"/> </menu:main>
You wish to put the full responsibility of generating output on the outer <menu:main>
tag handler, assuming that centralizing the display logic will be easier to maintain. The outer tag handler will need access to its descendent tags to accomplish this. Which of the following options provides the best approach?
A. | Every inner tag should register itself directly to its immediate parent. The immediate parent can store its children in an ordered collection. | |
B. | Every inner tag should register itself directly to the outer tag handler, and the outer tag handler can store them all in a single | |
C. | Unlike Classic tags, SimpleTagSupport provides the methods | |
D. | Have each inner tag save itself as a page scoped attribute with its text value as the attribute key. |
Which JSP life cycle phase can cause an HTTP 500 status code to be returned on a request to a JSP page? (Choose all that apply.)
Given that session
is a reference to a valid HttpSession
and "myAttr"
is the name of an object bound to session
, which can be used to unbind object(s) from a session? (Choose all that apply.)
If req
is a reference to an HttpServletRequest
and there is no current session, what is true about req.getSession()
? (Choose all that apply.)
A. | Invoking | |
B. | Invoking | |
C. | Invoking | |
D. | Invoking | |
E. | Invoking | |
F. | Invoking |
A Classic tag handler exists in legacy code. The author wrote a handler that evaluates its tag body a hundred times, to be used in testing other tags that produce random content.
Given:
06. public class HundredTimesTag extends TagSupport { 07. private int iterationCount; 08. public int doTag() throws JspException { 09. iterationCount = 0; 10. return EVAL_BODY_INCLUDE; 11. } 12. 13. public int doAfterBody() throws JspException { 14. if(iterationCount < 100){ 15. iterationCount++; 16. return EVAL_BODY_AGAIN; 17. }else{ 18. return SKIP_BODY; 19. } 20. } 21. }
What is incorrect about the code?
A. | Tag handlers are not thread safe, so the | |
B. | The | |
C. | The | |
D. | When |
Given this fragment from a web application’s DD:
72. <session-config> 73. <session-timeout>10</session-timeout> 74. </session-config>
And given that session
is a reference to a valid HttpSession
, and this fragment from a servlet:
30. session.setMaxInactiveInterval(120);
After line 30 executes, which are true? (Choose all that apply.)
A. | The DD fragment is not valid. | |
B. | The invocation of | |
C. | It is impossible to determine the session timeout limits given the above. | |
D. | If the container receives no client requests for this session in 2 hours, the container will invalidate the session. | |
E. | If the container receives no client requests for this session in 2 minutes, the container will invalidate the session. | |
F. | If the container receives no client requests for this session in 10 seconds, the container will invalidate the session. | |
G. | If the container receives no client requests for this session in 10 minutes, the container will invalidate the session. |
You have created a valid directory structure and a valid WAR
file for your Java EE web application. Given that:
- ValidApp.war
is the name of the WAR
file.
- WARdir
represents the directory that must exist in every WAR
file.
- APPdir
represents the directory that must exist in every web application.
Which is true?
A. | The actual name of | |
B. | The name of your application is NOT predictable. | |
C. | In this directory structure, | |
D. | In this directory structure, the application’s deployment descriptor will reside in the same directory as | |
E. | Placing your application in a |
When comparing HTTP GET
to HTTP POST
, what is true? (Choose all that apply.)
A. | Only HTTP | |
B. | Both require an explicit declaration in HTML form tags. | |
C. | Only HTTP | |
D. | Both support single parameter requests that send multiple values. | |
E. | Only HTTP |
Given this code in a servlet:
82. String s = getServletConfig().getInitParameter("myThing");
Which DD fragment will assign to s
the value "myStuff"
?
A. | <init-param> <param>myThing</param> <value>myStuff</value> </init-param> | |
B. | <init-param> <name>myThing</name> <value>myStuff</value> </init-param> | |
C. | <init-param> <param-name>myThing</param-name> <param-value>myStuff</param-value> </init-param> | |
D. | <servlet-param> <name>myThing</name> <value>myStuff</value> </servlet-param> | |
E. | <servlet-param> <param-name>myThing</param-name> <param-value>myStuff</param-value> </servlet-param> |
Given that a String is stored as an attribute named accountNumber
of some scope, which
scriptlet(s) will output the attribute?
A. |
| |
B. |
| |
C. | <% Object accNum = pageContext.getAttribute("accountNumber"); if(accNum == null){ accNum = request.getAttribute("accountNumber"); } if(accNum == null){ accNum = session.getAttribute("accountNumber"); } if(accNum == null){ accNum = servletContext.getAttribute("accountNumber"); } out.print(accNum); %> | |
D. |
|
You have inherited a legacy JSP web application with lots of scripting code. Your manager has demanded that every JSP be refactored to remove scripting code. He wants you to guarantee that no scriptlet code exists in your JSP codebase and to have the web container enforce a “no scripting” policy.
Which web.xml
configuration element will accomplish this goal?
A. | <jsp-property-group> <url-pattern> *.jsp </url-pattern> <permit-scripting> false </permit-scripting> </jsp-property-group> | |
B. | <jsp-config> <url-pattern> *.jsp </url-pattern> <permit-scripting> false </permit-scripting> </jsp-config> | |
C. | <jsp-property-group> <url-pattern> *.jsp </url-pattern> <scripting-invalid> true </scripting-invalid> </jsp-property-group> | |
D. | <jsp-config> <url-pattern> *.jsp </url-pattern> <scripting-invalid> true </scripting-invalid> </jsp-config> |
01. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 02. 03. <% 04. java.util.List books = new java.util.ArrayList(); 05. // add line here 06. request.setAttribute("myFavoriteBooks", books); 07. %> 08. 09. <c:choose> 10. <c:when test="${not empty myFavoriteBooks}"> 11. My favorite books are: 12. <c:forEach var="book" items="${myFavoriteBooks}"> 13. <br/> * ${book} 14. </c:forEach> 15. </c:when> 16. <c:otherwise> 17. I have not selected any favorite books. 18. </c:otherwise> 19. </c:choose>
Which of the following lines of code, if inserted independently at Line 5, will cause the text within the c:otherwise
tag to display? (Choose all that apply)
You are working on an application that manages a business listing directory.
Given:
29. <c:forEach var="phoneNumber" items='${company. contactInfo.phoneNumbers}'> 30. <c:if test='${verify:isTollFree(phoneNumber)}'> 31. <img src="/images/TollFree.gif"/> 32. </c:if> 33. ${phoneNumber}<br/> 34. </c:forEach>
The above snippet adds a special icon in front of phone numbers that are toll free. Which statement about the EL function from this code snippet is guaranteed to be true?
A. | The EL function must be declared public and static | |
B. | The EL function must not return any value and be declared void | |
C. | The | |
D. | The name of the class that implements the EL function must be named | |
E. | If |
Which are methods of HttpServletRequest
that retrieve the body of the request? (Choose all that apply.)
Given a Java EE web application in which the following browser request:
http://www.wickedlysmart.com/MyApp/myDir/DoSomething
will be handled by a servlet in the application, which three are true? (Choose three.)
A. | The deployment descriptor must include instructions to handle the request as specified. | |
B. | The request can be handled as specified with no related instructions in the deployment descriptor. | |
C. | The servlet that handles this request must be named | |
D. | The servlet name is not predictable based on the information provided. | |
E. | The application must contain a directory named | |
F. | The name of the directory in which the servlet resides is not predictable based on the information provided. |
Your web application has a valid deployment descriptor in which student
and sensei
are the only security roles that have been defined. The deployment descriptor contains two security constraints that declare the same resource to be constrained. The first security constraint contains:
234. <auth-constraint> 235. <role-name>student</role-name> 236. </auth-constraint>
And the second security constraint contains:
251. <auth-constraint>
Which are true? (Choose all that apply.)
A. | As the deployment descriptor stands now, the constrained resource can be accessed by both roles. | |
B. | As the deployment descriptor stands now, the constrained resource can be accessed only by | |
C. | As the deployment descriptor stands now, the constrained resource can be accessed only by | |
D. | If the second | |
E. | If the second | |
F. | If the second |
Which of the following custom tags is guaranteed to fail? (Choose all that apply)
A. | <mine:border> <mine:photos album="${albumSelected}"> </mine:border> </mine:photos> | |
B. | <mine:border> <mine:photos album="${albumSelected}"/> </mine:border> | |
C. | <mine:border> ${albumSelected.title} <mine:photos>${albumSelected}</mine:photos> </mine:border> | |
D. | <mine:photos includeBorder="${userPreference.border}" album="${albumSelected}" /> |
Your n-tier web application uses the Java EE patterns that are most typically used when such an application wants to access remote registries. Which are benefits of these patterns? (Choose all that apply.)
What is generally true about the lifecycle of a servlet? (Choose all that apply.)
A. | You should NOT write a constructor for a servlet. | |
B. | You should NOT override a servlet’s | |
C. | You should NOT override a servlet’s | |
D. | You should NOT override a servlet’s | |
E. | You should NOT override a servlet’s | |
F. | You should NOT override a servlet’s |
Given this portion of a Java EE .war
file’s directory structure:
MyApp |-- META-INF | |-- MANIFEST.MF | |-- web.xml | |-- WEB-INF | |-- index.html | |-- TLDs | |-- Header.tag
What change(s) are necessary to make this structure valid and the resources accessible? (Choose all that apply.)
You are considering implementing some variety of MVC in your Java EE n-tier application. Which are true? (Choose all that apply.)
A. | This design will often serve business delegate objects. | |
B. | It often reduces network traffic by caching remotely located data. | |
C. | This design goal simplifies communications with heterogeneous resource registries. | |
D. | Even though MVC solutions have many benefits, they often increase design complexity. | |
E. | Both the front controller pattern and Struts could be considered solutions for this design goal. | |
F. | This design will provide you with the capability to easily recombine request and response handlers. |
Given the following line of code from a JSP page:
<% List myList = new ArrayList(); %>
Which JSP code snippets can you use to import these data types? (Choose two.)
You are tasked with adding several security features to your company’s Java EE web application. Specifically, you need to create several classes of users and based on a user’s class, you need to restrict them to use only some of the application’s pages. In order to restrict access, you must determine that users are who they say they are.
Which are true? (Choose all that apply.)
A. | If you need to verify that users are who they say they are, you must use the application’s deployment descriptor to implement that requirement. | |
B. | Java EE’s authorization capabilities should be used to determine that users are who they say they are. | |
C. | In order to help you determine that users are who they say they are, you can use the deployment descriptor’s | |
D. | In order to help you determine that users are who they say they are, you can use the deployment descriptor’s |
ValidApp is a Java EE application with a valid directory structure. ValidApp contains .gif image files in three locations within the directory structure:
- ValidApp/imageDir/ - ValidApp/META-INF/ - ValidApp/WEB-INF/
In which of these locations can clients directly access these .gif files?
Given req
is a reference to a valid HttpServletRequest
, and:
13. String[] s = req.getCookies(); 14. Cookie[] c = req.getCookies(); 15. req.setAttribute("myAttr1", "42"); 16. String[] s2 = req.getAttributeNames(); 17. String[] s3 = req.getParameterValues("attr");
Which lines of code will not compile? (Choose all that apply.)
A Tag File named Products.tag
displays a list of products.
Given this snippet from the Tag File:
1. <%@ attribute name="header" required="false" rtexprvalue="false" %> 2. <%@ attribute name="products" required="true" rtexprvalue="true" %> 3. <%@ tag body-content="tagdependent" %>
Which of the following are legal usages of the Tag File? (Choose all that apply.)
A. |
| |
B. |
| |
C. | <display:Products header="Similar Products" products="${similarProducts}"> Customers who bought this item also bought: </display:Products> | |
D. |
|
You are taking part in an initiative to remove scriptlets from the JSPs of a legacy web application for a major bank. You come across the following lines of code:
<% if(((com.yourcompany.Account)request. getAttribute("account")). isPersonalChecking()){ %> Checking that fits your lifestyle. <% } %>
How can you replace this using JSTL? (Choose all that apply)
A. | <c:if test='${account.personalChecking}'>Checking that fits your lifestyle.</c:if> | |
B. | <c:if test='${account["personalChecking"]}'>Checking that fits your lifestyle.</c:if> | |
C. | <c:if test='${account['personalChecking']}'>Checking that fits your lifestyle.</c:if> | |
D. | <c:if test='${account.isPersonalChecking}'>Checking that fits your lifestyle.</c:if> |
Given the following event types:
- HttpSessionEvent - HttpSessionBindingEvent - HttpSessionAttributeEvent
Match the event types above to their respective listener interfaces. (Note: you can match an event type to more than one Listener
.)
| _______________________________ _______________________________ _______________________________ _______________________________ |
What’s true about the lifecycle of a servlet? (Choose all that apply.)
A. | The | |
B. | The | |
C. | Each time that | |
D. | The | |
E. | The container issues a separate thread for each client request. |
When might a JSP get translated? (Choose all that apply.)
Given this fragment from a valid doGet()
method:
12. OutputStream os = response.getOutputStream(); 13. byte[] ba = {1,2,3}; 14. os.write(ba); 15. RequestDispatcher rd = request.RequestDispatcher("my.jsp"); 16. rd.forward(request, response);
Assuming that "my.jsp"
adds the bytes 4
, 5
, and 6
to the response, what is the result?
A programmer needs to update a live, running servlet’s initialization parameters so that the web application will begin to use the new parameters immediately.
In order to accomplish this, which must be true (although not necessarily sufficient)? (Choose all that apply.)
A. | For each parameter, you must modify a DD tag that specifies the name of the servlet, the name of the parameter, and the new value of the parameter. | |
B. | The servlet’s constructor must retrieve the updated DD parameter from the servlet’s | |
C. | The container must destroy and then reinitialize the servlet. | |
D. | For each parameter, the DD must have a separate |
Which types can be used in conjunction with HttpServletResponse
methods to stream output data? (Choose all that apply.)
Your web application has a valid dd with a single <security-constraint>
tag. Within this tag exists:
- a single url pattern that declares directory1 - a single http method that declares POST - a single role name that declares GUEST
If all of the resources for your application exist within directory1
and directory2
, and MEMBER
is also a valid role, which are true? (Choose all that apply.)
Given:
1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/ jstl/core" %> 2. <%@ taglib prefix="tables" uri="http://www.javaranch. com/tables" %> 3. <%@ taglib prefix="jsp" tagdir="/WEB-INF/tags" %> 4. <%@ taglib uri="UtilityFunctions" prefix="util" %>
What about the above taglib directives would cause the JSP to not function?
Given that resp
is a reference to a valid HttpServletResponse
object that contains, among others, the following headers:
Content-Type: text/html MyHeader: mydata
And the following invocations:
25. resp.addHeader("MyHeader", "mydata2"); 26. resp.setHeader("MyHeader", "mydata3"); 27. resp.addHeader("MyHeader", "mydata");
What data will exist for the MyHeader
header?
Given the following portion of a web.xml from a legacy application:
<jsp-config> <taglib> <taglib-uri>prettyTables</taglib-uri> <taglib-location>/WEB-INF/tlds/prettyTables.tld</taglib-location> </taglib> </jsp-config>
Assuming the server running your code now supports Java 1.4 EE or greater, what could you do to remove the above <jsp-config>
tag and still have your code work?
A. | Change the taglib directive’s uri attribute in your JSPs to use | |
B. | Place | |
C. | Remove the | |
D. | This is impossible. The |
For a page that lists shopping cart items, the message “Your shopping cart is empty.” must display when the cart is empty. Which of the following code snippets could satisfy this functionality assuming the scoped attribute cart is a List of products? (Choose all that apply)
A. | <c:if test='${empty cart}'> Your shopping cart is empty. </c:if> <c:forEach var="itemInCart" items="${cart}"> <shop:displayItem item="${itemInCart}"/> </c:forEach> | |
B. | <c:forEach var="itemInCart" items="${cart}"> <c:choose> <c:when test='${empty itemInCart}'> Your shopping cart is empty. </c:when> <c:otherwise> <shop:displayItem item="${itemInCart}"/> </c:otherwise> </c:choose> </c:forEach> | |
C. | <c:choose> <c:when test='${empty cart}'> Your shopping cart is empty. </c:when> <c:when test='${not empty cart}'> <c:forEach var="itemInCart" items="${cart}"> <shop:displayItem item="${itemInCart}"/> </c:forEach> </c:when> </c:choose> | |
D. | <c:choose> <c:when test='${empty cart}'> Your shopping cart is empty. </c:when> <c:otherwise> <c:forEach var="itemInCart" items="${cart}"> <shop:displayItem item="${itemInCart}"/> </c:forEach> </c:otherwise> </c:choose> |
Given the following code from a servlet, and given that myVar
is a reference to either an HttpSession
or a ServletContext
:
15. myVar.setAttribute("myName", "myVal"); 16. String s = (String) myVar.getAttribute("myName"); 17. // more code
After line 16 executes, which are true? (Choose all that apply.)
Given a portion of Java EE web application’s deployment descriptor:
62. <error-page> 63. <exception-type>IOException</exception-type> 64. <location>/mainError.jsp</location> 65. </error-page> 66. <error-page> 67. <error-code>404</error-code> 68. <location>/notFound.jsp</location> 69. </error-page>
What is true?
1. <%! String GREETING = "Welcome to my page"; %> 2. <% request.setAttribute("greeting", GREETING); %> 3. Greeting: ${greeting} 4. Again: <%= request.getAttribute("greeting") %>
An attempt is made to convert the above JSP to a JSP Document:
01. <jsp:declaration> 02. String GREETING = "Welcome to my page"; 03. </jsp:declaration> 04. <jsp:scriptlet> 05. request.setAttribute("greeting", GREETING); 06. </jsp:scriptlet> 07. Greeting: ${greeting} 08. Again: <jsp:expression> 09. request.getAttribute("greeting"); 10.</jsp:expression>
What is wrong with the new JSP Document? (Choose all that apply.)
Which of the following is LEAST likely to make or receive network calls?
10. ${questionNumber}: ${question} 11. <c:forEach var="answer" items="${answers}"> ... 16. </c:forEach>
The question attribute is a String that may contain XML tags that must be displayed in the browser as regular text. With the above snippet, the browser is not displaying the XML tags. What can be changed to fix this? (Choose all that apply)
Your Java EE web application is gaining in popularity and you decide to add a second server to support the volume of client requests. Which are true about the migration of a session from one server to the other? (Choose all that apply.)
A. | Such migrations are not possible within a session. | |
B. | When a session is migrated, its | |
C. | When a session is migrated, its | |
D. | When a session is migrated, its | |
E. | If an object is added using | |
F. | If an object is added using | |
G. | If a session attribute implements |
A Java EE deployment descriptor declares several filters whose URLs match a given request, and also declares several filters whose <servlet-name>
tags match the same request.
What statements are true about the rules that the container uses to invoke the filter(s) for that request? (Choose all that apply.)
A. | Only the | |
B. | Of the URL matched filters, only the first will be invoked. | |
C. | Of the | |
D. | The | |
E. | All of the URL matched filters will be invoked, but the order of invocation is undefined. | |
F. | All of the URL matched filters will be invoked, in the order in which they appear in the DD. |
When comparing servlet initialization parameters to context initialization parameters, which are true for both? (Choose all that apply.)
A. | In their respective DD tags, they both have a | |
B. | Their respective DD tags are both placed directly under the | |
C. | Their respective methods used to retrieve initialization parameter values are both called | |
D. | Both can be directly accessed from a JSP using the Expression Language. | |
E. | Only changes to context initialization parameters in the DD can be accessed without redeploying the web application. |
A JSP developer wants to include the contents of the file copyright.jsp
into all primary JSP pages.
Which mechanisms can do this? (Choose all that apply.)
You are developing an application to manage customer accounts for a company that offers phone, cable, and Internet services. Many of the pages contain a search functionality. The search box should look the same on every page but some of the pages should limit the search to only phone, cable, or Internet accounts.
Given a separate JSP named Search.jsp:
1. <form action="/search.go"> 2. Find ${param.accountType} Account: 2. <input type="text" name="searchText"/> 3. <input type="hidden" name="accountType" value="${param.accountType}"/> 3. <input type="submit" value="Search " 4. </form>
What tag should you use in a JSP that needs to search for cable accounts?
A. |
| |
B. | <jsp:include page="Search.jsp"> <jsp:param name="accountType" value="Cable"/> </jsp:include> | |
C. |
| |
D. | <jsp:include file="Search.jsp"> <jsp:attribute name="accountType" value="Cable"/> </jsp:include> |
While testing how various tags and scriptlets work, a developer creates the following JSP:
1. <% request.setAttribute("name", "World"); %> 2. <!-- Test --> 3. <c:out value='Hello, ${name}'/>
Much to the developer’s surprise, the browser doesn’t display anything at all when her JSP is retrieved. If the developer views the HTML source of the page, what will she find in the output?
A dating services application asks its single users a series of questions. A session scoped attribute called compatibilityProfile
of type HashMap
already exists, into which each submitted question ID and answer pair are stored.
Given:
22. <% ((java.util.HashMap)request.getSession().getAttribute(" compatibilityProfile")).put( 23. request.getParameter("questionIdSubmitted"), 24. request.getParameter("answerSubmitted")); 25. %>
How can this be replaced without using scriptlets? (Choose all that apply)
A. | <c:map target="${compatibilityProfile}" key="${param.questionIdSubmitted}" value="${param.answerSubmitted}"/> | |
B. | <jsp:useBean id="compatibilityProfile" class="java.util.HashMap" scope="session"> <jsp:setProperty name="compatibilityProfile" property="${param.questionIdSubmitted}" value="${param.answerSubmitted}"/> </jsp:useBean> | |
C. | ${compatibilityProfile[param.questionIdSubmitted] = param.answerSubmitted} | |
D. | <c:set target="${compatibilityProfile}" property="${param.questionIdSubmitted}" value="${param.answerSubmitted}"/> |
A programmer is creating a filter for a Java EE web application. Given the following code:
7. public class MyFilter implements Filter { 8. public void init(FilterConfig config) throws FilterException { } 9. 10. public void doFilter(HttpServletRequest request, 11. HttpServletResponse response, 12. FilterChain chain) 13. throws IOException, ServletException { } 14. 15. }
What change(s) are necessary to create a valid filter? (Choose all that apply.)
Your company wants to include a splash page, SplashAd.jsp
, to advertise other company offerings to users as they first enter the site. On this new page users will be given the option to click a checkbox on the ad page that says“Do not show me this offer again” and click a submit button that says “Continue to My Account”. If the user submits this form with the checkbox checked, the receiving Servlet sets a Cookie with the name of “skipSplashAd”to the user’s browser and then passes control back to the main JSP.
The main JSP will be responsible for forwarding the request to the splash page What snippet can be added to the top of the main page to send the user to the splash page if they have not yet selected the checkbox to avoid the ad offer?
A. | <c:if test="${empty cookie.skipSplashAd and pageContext.session.new}"> <jsp:forward page="SplashAd.jsp"/> </c:if> | |
B. |
| |
C. |
| |
D. |
| |
E. | <% if(cookie.get("skipSplashAd") == null && session.isNew()){ %> <jsp:forward page="SplashAd.jsp"/> <% } %> |
A programmer wants to implement a ServletContextListener
. Given the following DD fragment:
101. <!-- insert tag1 here --> 102. <param-name>myParam</param-name> 103. <param-value>myValue</param-value> 104. <!-- close tag1 here --> 105. <listener> 106. <!-- insert tag2 here --> 107. com.wickedlysmart.MySCListener 108. <!-- close tag2 here --> 109. </listener>
And this listener class pseudo-code:
5. // packages and imports here 6. public class MySCListener implements ServletContextListener { 7. // method 1 here 8. // shutdown related method here 9. }
Which are true? (Choose all that apply.)
The wickedlysmart website has a validly deployed Java EE web application and Deployment descriptor that contains the following:
<welcome-file-list> <welcome-file>welcome.html</welcome-file> <welcome-file>howdy.html</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list>
A portion of the web app’s directory structure looks like this:
MyWebApp | |-- index.html | |-- welcome | |-- welcome.html | |-- foobar | |-- howdy.html
If the application receives the following two requests:
http://www.wickedlysmart.com/MyWebApp/foobar http://www.wickedlysmart.com/MyWebApp
Which set of responses will be served?
Your web application has a valid dd with a single <security-constraint>
tag. Within this tag exists:
- a single http method that declares GET
All of the resources in your application exist within directory1
and directory2
and the only defined roles are BEGINNER
and EXPERT
.
If you want to restrict BEGINNER
s from retrieving static resources in directory2
, which are true about the url and role tag(s) you should declare? (Choose all that apply.)
A. | A single url tag should declare | |
B. | A single url tag should declare | |
C. | A single url tag should declare | |
D. | A single url tag should declare | |
E. | One url tag should declare | |
F. | One url tag should declare both directories, and its role tag should declare |