Page: 3
UNIT-6: The JavaServer Pages (JSP) Technology Model
Q5. You have created a JSP that includes instance variables and a great deal of scriptlet code. Unfortunately, after extensive load testing, you have discovered several race conditions in your JSP scriptlet code. To fix these problems would require significant recoding, but you are already behind schedule. Which JSP code snippet can you use to resolve these concurrency problems? A. <%@ page isThreadSafe='false' %> B. <%@ implements SingleThreadModel %> C. <%! implements SingleThreadModel %> D. <%@ page useSingleThreadModel='true' %> E. <%@ page implements='SingleThreadModel' %> Answer: A Q6. 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? A. <%! int count = 0; %> <% if ( request.getSession(false) == null ) count++; %> B. <%@ int count = 0; %> <% if ( request.getSession(false) == null ) count++; %> C. <% int count = 0; if ( request.getSession(false) == null ) count++; %> D. <%@ int count = 0; if ( request.getSession(false) == null ) count++; %> E. <%! int count = 0; if ( request.getSession(false) == null ) count++; %> Answer: A Q7. 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? A. <jsp:declaration> int count = 0; <jsp:declaration> B. <%! int count = 0; %> C. <jsp:declaration.instance> int count = 0; <jsp:declaration.instance> D. <jsp:scriptlet.declaration> int count = 0; <jsp:scriptlet.declaration> Answer: A
Page: 3
1
2
3
4
5
6
7
8
9
10
|