You are creating a new JSP page and you need to execute some code that acts when the page is firstexecuted, but only once.
Which three are possible mechanisms for performing this initialization code?()
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.
您可能感興趣的試卷
你可能感興趣的試題
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>
In a JSP-centric web application, you need to create a catalog browsing JSP page. The catalog is stored asa List object in the catalog attribute of the webapp’s ServletContext object.
Which scriptlet code snippetgives 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"); %>
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 snippetmust 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>
For debugging purposes, you need to record how many times a given JSP is invoked before the user’ssession has been created. The JSP’s destroy method stores this information to a database.
Which JSPcode 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++; %>
You are building JSP pages that have a set of menus that are visible based on a user’s security role. Thesemenus are hand-crafted by your web design team; for example, the SalesManager role has a menu in thefile /WEB-INF/html/sales-mgr-menu.html.
Which JSP code snippet should be used to make this menuvisible to the user?()
A.<% if ( request.isUserInRole("SalesManager") ) { %> <%@ include file=’/WEB-INF/html/sales-mgr-menu.html’ %> <% } %>
B.<jsp:if test=’request.isUserInRole("SalesManager")’> <%@ include file=’/WEB-INF/html/sales-mgr-menu.html’ %> </jsp:if>
C.<% if ( request.isUserInRole("SalesManager") ) { %> . <jsp:include file=’/WEB-INF/html/sales-mgr-menu.html’ /> . <% } %>
D.<jsp:if test=’request.isUserInRole("SalesManager")’> <jsp:include file=’/WEB-INF/html/sales-mgr-menu.html’ /> </jsp:if>
最新試題
Click the ’Select and Place’ button.Place the events in the order they occur.
A web application allows the HTML title banner to be set using a servlet context initialization parametercalled titleStr.Which two properly set the title in this scenario?()
Click the ’Select and Place’ button.Place the events in the order they occur.
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?()
You are building your own layout mechanism by including dynamic content for the page’s header and footersections. The footer is always static, but the header generates the <title> tag that requires the page name tobe specified dynamically when the header is imported.Which JSP code snippet performs the import of theheader content?()
Click the Exhibit button.The attribute "name" has a value of "Foo,"What is the result if this tag handler’s tag is invoked?()
Given a web application in which the request parameter productID contains a product identifier.Which twoEL expressions evaluate the value of the productID?()
A web browser need NOT always perform a complete request for a particular page that it suspects mightNOT have changed. The HTTP specification provides a mechanism for the browser to retrieve only a partialresponse from the web server; this response includes information, such as the Last-Modified date but NOTthe body of the page.Which HTTP method will the browser use to retrieve such a partial response?()
Click the 'Select and Place' button.Place the events in the order they occur.
All of your JSPs need to have a link that permits users to email the web master. This web application islicensed to many small businesses, each of which have a different email address for the web master. Youhave decided to use a context parameter that you specify in the deployment descriptor, like this:42.<context-param>43.<param-name>webmasterEmail</param-name>44.<param-value>master@example.com</param-value>45.</context-param>Which JSP code snippet creates this email link?()