Page: 4
UNIT-6: The JavaServer Pages (JSP) Technology Model
Q8. 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? A. <% List catalog = config.getAttribute("catalog"); %> B. <% List catalog = context.getAttribute("catalog"); %> C. <% List catalog = application.getAttribute("catalog"); %> D. <% List catalog = servletContext.getAttribute("catalog"); %> Answer: C Q9. Given the element from the web application deployment descriptor: <jsp-property-group> <url-pattern>/main/page1.jsp</url-pattern> <scripting-invalid>true</scripting-invalid> </jsp-property-group> and given that /main/page1.jsp contains: <% int i = 12; %> <b><%= i %></b> What is the result? A. <b></b> B. <b>12</b> C. The JSP fails to execute. D. <% int i = 12 %> <b><%= i %></b> Answer: C Q10. 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 hree.) A. In the init method. B. In the jspInit method. C. In the constructor of the JSP's Java code. D. In a JSP declaration, which includes an initializer block. E. In a JSP declaration, which includes a static initializer block. Answer: B, D, E Q11. You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to an ArrayList object. Which two JSP code snippets can you use to import these list types? (Choose two.) A. <%! import java.util.*; %> B. <%! import java.util.List; import java.util.ArrayList; %> C. <%@ page import='java.util.List' import='java.util.ArrayList' %> D. <%@ import types='java.util.List' types='java.util.ArrayList' %> E. <%@ page import='java.util.List,java.util.ArrayList' %> F. <%@ import types='java.util.List,java.util.ArrayList' %> Answer: C, E
Page: 4
1
2
3
4
5
6
7
8
9
10
|