单选题Your web application uses a simple architecture in which servlets handle requests and then forward to aJSP using a request dispatcher. You need to pass information calculated by the servlet to the JSP;furthermore, that JSP uses a custom tag and must al

题目
单选题
Your web application uses a simple architecture in which servlets handle requests and then forward to aJSP using a request dispatcher. You need to pass information calculated by the servlet to the JSP;furthermore, that JSP uses a custom tag and must also process this information. This information mustNOT be accessible to any other servlet, JSP or session in the webapp. How can you accomplish this goal?()
A

Store the data in a public instance variable in the servlet.

B

Add an attribute to the request object before using the request dispatcher.

C

Add an attribute to the context object before using the request dispatcher.

D

This CANNOT be done as the tag handler has no means to extract this data.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Your web application uses a simple architecture in which servlets handle requests and then forward to aJSP using a request dispatcher. You need to pass information calculated by the servlet to the JSP;furthermore, that JSP uses a custom tag and must also process this information. This information mustNOT be accessible to any other servlet, JSP or session in the webapp. How can you accomplish this goal?()

  • A、Store the data in a public instance variable in the servlet.
  • B、Add an attribute to the request object before using the request dispatcher.
  • C、Add an attribute to the context object before using the request dispatcher.
  • D、This CANNOT be done as the tag handler has no means to extract this data.

正确答案:B

第2题:

If you want to use the Java EE platform’s built-in type of authentication that uses a custom HTML page for authentication. Which two statements are true?()

  • A、Your deployment descriptor will need to contain this tag: CUSTOM.
  • B、The related custom HTML login page must be named loginPage.html.
  • C、When you use this type of authentication, SSL is turned on automatically.
  • D、You must have a tag in your deployment descriptor that allows you to point to both a login HTML pageand an HTML page for handling any login errors.
  • E、In the HTML related to authentication for this application, you must use predefined variable names fort he variables that store the user and password values.

正确答案:D,E

第3题:

Servlet A receives a request that it forwards to servlet B within another web application in the same webcontainer. Servlet A needs to share data with servlet B and that data must not be visible to other servlets inA’s web application. In which object can the data that A shares with B be stored?()

  • A、HttpSession
  • B、ServletConfig
  • C、ServletContext
  • D、HttpServletRequest
  • E、HttpServletResponse

正确答案:D

第4题:

A web application contains a tag file called beta.tag in /WEB-INF/tags/alpha. A JSP page called sort.jspexists in the web application and contains only this JSP code: 1.<%@ taglib prefix="x" 2.tagdir="/WEB-INF/tags/alpha" %> 3. The sort.jsp page is requested. Which two are true?()

  • A、Tag files can only be accessed using a tagdir attribute.
  • B、The sort.jsp page translates successfully and invokes the tag defined by beta.tag.
  • C、The sort.jsp page produces a translation error because a taglib directive must always have a uriattribute.
  • D、Tag files can only be placed in /WEB-INF/tags, and NOT in any subdirectories of /WEB- INF/tags.
  • E、The tagdir attribute in line 2 can be replaced by a uri attribute if a TLD referring to beta.tag is createdand added to the web application.

正确答案:B,E

第5题:

To take advantage of the capabilities of modern browsers that use web standards, such as XHTML andCSS, your web application is being converted from simple JSP pages to JSP Document format. However,one of your JSPs, /scripts/screenFunctions.jsp, generates a JavaScript file. This file is included in severalweb forms to create screen-specific validation functions and are included in these pages with the followingstatement: 10. 11.  14. 15. Which JSP code snippet declares that this JSP Document is a JavaScript file?()

  • A、<%@ page contentType=’application/javascript’ %>
  • B、<jsp:page contentType='application/javascript' />
  • C、<jsp:document contentType='application/javascript' />
  • D、<jsp:directive.page contentType='application/javascript' />
  • E、No declaration is needed because the web form XHTML page already declares the MIME type of the /scripts/screenFunctions.jsp file in the <script> tag.

正确答案:D

第6题:

A custom JSP tag must be able to support an arbitrary number of attributes whose names are unknown when the tag class is designed.  Which two are true? ()

  • A、 A  element in the echo tag LTD must have the value JSP
  • B、 The echo tag handler must define the setAttribute (String key, String value) method
  • C、 The true element must appear in the echo tag TLD
  • D、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.IterationTag interface
  • E、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.DynamicAttributes interface

正确答案:C,E

第7题:

Your IT department is building a lightweight Front Controller servlet that invokes an application logic objectwith the interface: public interface ApplicationController {public String invoke(HttpServletRequest request)} The return value of this method indicates a symbolic name of the next view. From this name, the FrontController servlet looks up the JSP URL in a configuration table. This URL might be an absolute path or apath relative to the current request. Next, the Front Controller servlet must send the request to this JSP togenerate the view. Assume that the servlet variable request is assigned the current HttpServletRequestobject and the variable context is assigned the webapp’s ServletContext. Which code snippet of the FrontController servlet accomplishes this goal?()

  • A、Dispatcher view=context.getDispatcher(viewURL);view.forward Request(request, response);
  • B、Dispatcher view=request.getDispatcher(viewURL);view.forward Request(request, response);
  • C、RequestDispatcher view. =context.getRequestDispatcher(viewURL);view.forward(request,response);
  • D、RequestDispatcher view=request.getRequestDispatcher(viewURL);view.forward(request, response);

正确答案:D

第8题:

You are creating a content management system (CMS) with a web application front-end. The JSP thatdisplays a given document in the CMS has the following general structure: 1. <%-- tag declaration --%> 2.  ... 11. ...  ... ... 99.  The citation tag must store information in the document tag for the document tag to generate a referencesection at the end of the generated web page. The document tag handler follows the Classic tag model andthe citation tag handler follows the Simple tag model. Furthermore, the citation tag could also be embeddedin other custom tags that could have either the Classic or Simple tag handler model. Which tag handlermethod allows the citation tag to access the document tag?()

  • A、public void doTag() {JspTag docTag = findAncestorWithClass(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID);}
  • B、public void doStartTag() {JspTag docTag = findAncestorWithClass(this, DocumentTag.class); ((DocumentTag)docTag).addCitation(this.docID);}
  • C、public void doTag() {. Tag docTag = findAncestor(this, DocumentTag.class); . ((DocumentTag)docTag).addCitation(this.docID);. }
  • D、public void doStartTag() {. Tag docTag = findAncestor(this, DocumentTag.class); . ((DocumentTag)docTag).addCitation(this.docID);. }

正确答案:A

第9题:

You have built your own light-weight templating mechanism. Your servlets, which handle each request,dispatch the request to one of a small set of template JSP pages. Each template JSP controls the layout ofthe view by inserting the header, body, and footer elements into specific locations within the template page.The URLs for these three elements are stored in request scoped variables called, headerURL, bodyURL,and footerURL, respectively. These attribute names are never used for other purposes. Which JSP codesnippet should be used in the template JSP to insert the JSP content for the body of the page?()

  • A、<jsp:insert page=’${bodyURL}’ />
  • B、<jsp:insert file=’${bodyURL}’ />
  • C、<jsp:include page=’${bodyURL}’ />
  • D、<jsp:include file=’${bodyURL}’ />
  • E、<jsp:insert page=’<%= bodyURL %>’ />

正确答案:C

第10题:

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>

正确答案:A

更多相关问题