Given an HTML form that uses checkboxes to allow a user to select multiple values for a parameter called hobbies
.
(JSP v2.0 sections 2.2.3)
Which EL expressions evaluate to the first value of the hobbies
parameter? (Choose all that apply.)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
| |
F. |
|
Given that a web application stores the webmaster email address in the servlet context initialization parameter called master-email
.
(JSP v2.0 sections 2.2.3 and 2.3.4)
Which retrieves that value? (Choose all that apply.)
A. | <a href='mailto:${initParam.master-email}'> email me</a> | |
B. | <a href='mailto:${contextParam.master-email}'> email me</a> | |
C. | <a href='mailto:${initParam['master-email']}'> email me</a> | |
D. | <a href='mailto:${contextParam['master-email']}'> email me</a> |
Given the following Java class:
1. package com.mycompany; 2. public class MyFunctions { 3. public static String hello(String name) { 4. return "Hello "+name; 5. } 6. }
(JSP v2.0 section 2.6.3)
This class represents the handler for a function that is part of a tag library. <%@ taglib uri=" http://mycompany.com.tags" prefix="comp" %>
Which Tag Library Descriptor entry defines this custom function so that it can be used in an EL expression?
A. | <taglib> ... <tag> <name>Hello</name> <tag-class>com.mycompany.MyFunctions</tag-class> <body-content>JSP</body-content> </tag> </taglib> | |
B. | <taglib> ... <function> <name>Hello</name> <function-class>com.mycompany.MyFunctions</function-class> <function-signature>java.lang.String hello(java.lang.String) </function-signature> </function> </taglib> | |
C. | <web-app> ... <servlet> <servlet-name>hello</servlet-name> <servlet-class>com.mycompany.MyFunctions</servlet-class> </servlet> </web-app> | |
D. | <taglib> ... <function> <name>Hello</name> <function-class>com.mycompany.MyFunctions</function-class> <function-signature>hello(java.lang.String)</function-signature> </function> </taglib> |
Given:
1. package com.example; 2. public class TheBean { 3. private int value; 4. public TheBean() { value = 42; } 5. public int getValue() { return value; } 6. public void setValue(int v) { value = v; } 7. }
(JSP v2.0 section 5.1)
Assuming no instances of TheBean
have been created yet, which JSP standard action statements create a new instance of this bean and store it in the request scope? (Choose all that apply.)
A. | <jsp:useBean name="myBean" type="com.example.TheBean" /> | |
B. | <jsp:makeBean name="myBean" type="com.example.TheBean" /> | |
C. | <jsp:useBean id="myBean" class="com.example.TheBean" scope="request" /> | |
D. | <jsp:makeBean id="myBean" class="com.example.TheBean" scope="request" /> |
Given a Model 1 architecture in which a JSP page handles all of the controller functions, that JSP controller needs to dispatch the request to another JSP page.
(JSP v2.0 section 5.5)
Which standard action code will perform this dispatch?
A. |
| |
B. |
| |
C. |
| |
D. |
|
Given:
<% java.util.List list = new java.util.ArrayList(); list.add("a"); list.add("2"); list.add("c"); request.setAttribute("list", list); request.setAttribute("listIdx", "1"); %> <%-- insert code here --%>
(JSP v2.0 section 2.3.4)
Which, inserted at line 18, are valid and evaluate to c
? (Choose all that apply.)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
| |
F. |
|
Which statements about the . (dot) and []
EL operators are true? (Choose all that apply.)
(JSP v2.0 pg. 1-69 )
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
| |
F. |
|
Given a JSP page with the line:
${101 % 10}
(JSP v2.0 pg. 1-71)
What will be displayed?
Given:
10. ${param.firstname} 11. ${param.middlename} 12. ${param.lastname} 13. ${paramValues.lastname[0]}
(JSP v2.0 pg 1-67 and pg 1-79)
Which describes the output produced by this portion of a JSP page when passed the query string ?firstname=John&lastname=Doe
?
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. | A null pointer exception will be thrown. |
Which show valid usage of EL implicit variables? (Choose all that apply.)
(JSP v2.0 pg. 1-66)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
| |
F. |
| |
G. |
|
Which are true about the <jsp:useBean>
standard action? (Choose all that apply.)
(JSP v2.0 pgs. 1-103 and pg. 1-104)
A. | The | |
B. | The | |
C. | The | |
D. | Either the | |
E. | It is valid to include both the |
How would you include dynamic content in a JSP, similar to a server-side include (SSI)? (Choose all that apply.)
(JSP v2.0 section 5.4)
A. |
| |
B. |
| |
C. |
| |
D. | RequestDispatcher dispatcher = request.getRequestDispatcher("/segments/footer.jspf"); dispatcher.include(request,response); |
In an HTML page with a rich, graphical layout, which JSP standard action can be used to import an image file into the JSP page?
(JSP v2.0 section 5.4)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. | This CANNOT be done using a JSP standard action. |
-Options A and B are invalid because there is no image standard action.
-Option C is invalid, not because the syntax of the include action is wrong, but because it does not make sense to import the binary data of the image file into the JSP content.
-Option D is invalid because the include action does not take a file attribute.
This is a tricky question because it is NOT possible to import the contents of any binary file into a JSP page, which generates an HTML response.
Given:
1. package com.example; 2. public class MyFunctions { 3. public static String repeat(int x, String str) { 4. // method body 5. } 6. }
and given the JSP:
1. <%@ taglib uri="/WEB-INF/myfuncts" prefix="my" %> 2. <%-- insert code here --%>
(JSP v2.0 section 2.6)
Which, inserted at line 2 in the JSP, is a valid EL function invocation?
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. | A valid invocation CANNOT be determined. |
Given:
10. public class MyBean { 11. private java.util.Map params; 12. private java.util.List objects; 13. private String name; 14. public java.util.Map getParams() { return params; } 15. public String getName() { return name; } 16. public java.util.List getObjects() { return objects; } 17. }
(JSP v2.0 pg. 1-68)
Which will cause errors (assume that an attribute named mybean
can be found, and is of type MyBean
)? (Choose all that apply.)
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
| |
F. |
|
Given a JSP page:
1. The user has sufficiently logged in or out: 2. ${param.loggedIn or param.loggedOut}.
(JSP v2.0 pgs 1-66 and 1-73)
If the request includes the query string “loggedOut=true",
what will be this statement’s displayed value?
A. |
| |
B. |
| |
C. |
| |
D. |
| |
E. |
|
Which about EL access operators are true? (Choose all that apply.)
(JSP v2.0 pg. 1-69)
A. | Anywhere the . (dot) operator is used, the | |
B. | Anywhere the | |
C. | If the | |
D. | There are some situations where the |
The following code fragment appears in a JSP page:
<jsp:include page="/jspf/header.html"/>
(JSP v2.0 section 5.4)
The JSP page is part of a web application with the context root myapp
.
Given that the application’s top level directory is myapp
, what is the path to the header.html
file?
An online jewelry retailer wishes to customize their online catalog for users who are logged in. They want to show specials for the user’s birthstone month. The company’s special offers are stored as a Map<String, Special[]>
identified as specials
in application scope and updated daily.
(JSP v2.0 section 2.3.4)
There is a bean stored as a session-scoped attribute named userInfo
. Calling getBirthdate().getMonth()
on this bean will return the user’s birthstone month.
Which of the following code snippets could correctly retrieve the appropriate special offerings?
A. |
| |
B. |
| |
C. |
| |
D. |
|
-Option B correctly retrieves our Map<String, Special[]> from the application scope. It then attempts to get the month value from the user’s birthday and uses that as the key to search for a Special[] in the Map. Assuming a match is found in the Map, our Special[] is returned. This EL could be used in a c: forEach tag to iterate over the returned specials.
A web based application for a major online movie rental retailer stores a List<Movie>
as a session attribute to contain movies the user has requested. A random, embedded movie trailer from this list must display on the users’ main page every time the users’ main page is viewed.
(JSP v2.0 section 2.6)
Management thinks a similar feature will be needed in the near future on other pages that display lists of movies. Streaming video is accomplished with regular HTML, just like adding images to a page but with more complex tags.
The development team needs a solution that is both flexible and maintainable. One possible solution is to create an EL function. The following statements are from a team meeting concerning EL functions as a solution to this problem. Which statements are true? (Choose all that apply.)
A. | EL functions can not solve this problem because they can not retrieve session attributes. | |
B. | The method implementing the EL function should not be declared static to give it access to session scope. | |
C. | The EL function can accept a parameter of | |
D. | You might have to write HTML tags in the middle of Java code using an EL function, which is more difficult to maintain. |
-Option A: the movie list can be passed as a parameter to the function.
-Option B: methods that implement EL functions must always be declared public and static.
-Option C: a List may be passed to the function. Doing so provides a more flexible solution than one that requires your EL function to handle session scope as in options a and b.
-Option D: the biggest reason not to choose an EL function as the total solution. The team chose to use a tag file as the solution but then also created an EL function that accepts a Collection and returns a random number based on the size of the collection.