单项选择题

Given an HttpServletRequest request and an HttpServletResponse response:
41.HttpSession session = null;
42.// insert code here
43.if(session == null) {
44.// do something if session does not exist
45.} else {
46.// do something if session exists47. }
To implement the design intent,which statement must be inserted at line 42?()

A.session = response.getSession();
B.session = request.getSession();
C.session = request.getSession(true);
D.session = request.getSession(false);
E.session = request.getSession("jsessionid");


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题Which two statements are true about using the isUserInRole method to implement security in a Java EEapplication?()

A.It can be invoked only from the doGet or doPost methods.
B.It can be used independently of the getRemoteUser method.
C.Can return "true" even when its argument is NOT defined as a valid role name in the deployment descriptor.
D.Using the isUserInRole method overrides any declarative authentication related to the method in which it is invoked.

2.多项选择题Which two are required elements for the  element of a web applicationdeployment descriptor?()

A.<realm-name>
B.<url-pattern>
C.<description>
D.<web-resource-name>
E.<transport-guarantee>

3.单项选择题Which element of a web application deployment descriptor  element is required?()

A.<realm-name>
B.<auth-method>
C.<security-role>
D.<transport-guarantee>
E.<web-resource-collection>

4.多项选择题Which two statements are true about the security-related tags in a valid Java EE deployment descriptor?()

A.Every  tag must have at least one  tag.
B.A  tag can have many  tags.
C.A given  tag can apply to only one  tag.
D.A given  tag can contain from zero to many  tags.
E.It is possible to construct a valid  tag such that,for a given resource,no user rolescan access that resource.

6.多项选择题Which two are true concerning the objects available to developers creating tag files?()

A.The session object must be declared explicitly.
B.The request and response objects are available implicitly.
C.The output stream is available through the implicit outStream object.
D.The servlet context is available through the implicit servletContext object.
E.The JspContext for the tag file is available through the implicit jspContext object.

7.单项选择题

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. <t:document>
...
11. <t:paragraph>... <t:citation docID=’xyz’ /> ...</t:paragraph> ...
99. </t:document>
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);. }

8.多项选择题

Given:
3.public class MyTagHandler extends TagSupport {
4.public int doStartTag() {
5.// insert code here
6.// return an int
7.}
8.// more code here
...
18.}
There is a single attribute foo in the session scope.
Which three code fragments,inserted independently atline 5,return the value of the attribute?()

A.Object o = pageContext.getAttribute("foo");
B.Object o = pageContext.findAttribute("foo");
C.Object o = pageContext.getAttribute("foo",PageContext.SESSION_SCOPE);
D.HttpSession s = pageContext.getSession();Object o = s.getAttribute("foo");

10.多项选择题

Click the Exhibit button.

A servlet sets a session-scoped attribute product with an instance of com.example.Product and forwards toa JSP.
Which two output the name of the product in the response?()

A.${product.name}
B.<jsp:getProperty name="product" property="name" />
C.<jsp:useBean id="com.example.Product" /><%= product.getName() %>
D.<jsp:getProperty name="product" class="com.example.Product" property="name" />

最新试题

Which three are true about servlet filters?()

题型:多项选择题

Click the ’Select and Place’ button.Place the events in the order they occur.

题型:问答题

You are building a dating web site. The client’s date of birth is collected along with lots of other information.The Person class has a derived method, getAge():int, which returns the person’s age calculated from thedate of birth and today’s date. In one of your JSPs you need to print a special message to clients within theage group of 25 through 35.Which two EL code snippets will return true for this condition? ()

题型:多项选择题

In which three directories, relative to a web application’s root, may a tag library descriptor file reside whendeployed directly into a web application?()

题型:多项选择题

Click the ’Select and Place’ button.Place the events in the order they occur.

题型:问答题

Which ensures that a JSP response is of type "text/plain"?()

题型:单项选择题

Click the ’Select and Place’ button.Place the events in the order they occur.

题型:问答题

Click the ’Select and Place’ button.Place the events in the order they occur.

题型:问答题

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?()

题型:单项选择题

Which is true about the web container request processing model?()

题型:单项选择题