单选题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

题目
单选题
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++; %>

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

第1题:

Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in th epage being invoked?()

  • A、 Error
  • B、 Exception
  • C、 Throwable
  • D、 Request error
  • E、 Request exception

正确答案:B

第2题:

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++; %>

正确答案:A

第3题:

An E-commerce shopping cart ()

A、stores information about your purchases

B、allows you to change items quantities

C、Keeps a running count of items

D、keeps a running total of items


参考答案:ABCD

第4题:

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  tag that requires the page name tobe specified dynamically when the header is imported. Which JSP code snippet performs the import of theheader content?() <title>

  • A、<jsp:include page=’/WEB-INF/jsp/header.jsp’><jsp:param name=’pageName’ value=’Welcome Page’ /> </jsp:include>
  • B、<jsp:import page=’/WEB-INF/jsp/header.jsp’><jsp:param name=’pageName’ value=’Welcome Page’ /> </jsp:import>
  • C、<jsp:include page=’/WEB-INF/jsp/header.jsp’><jsp:attribute name=’pageName’ value=’Welcome Page’ /> . </jsp:include>
  • D、<jsp:import page=’/WEB-INF/jsp/header.jsp’>. <jsp:attribute name=’pageName’ value=’Welcome Page’ /> . </jsp:import>

正确答案:A

第5题:

You need to create a servlet filter that stores all request headers to a database for all requests to the webapplication’s home page "/index.jsp". Which HttpServletRequest method allows you to retrieve all of therequest headers?()

  • A、String[] getHeaderNames()
  • B、String[] getRequestHeaders()
  • C、java.util.Iterator getHeaderNames()
  • D、java.util.Iterator getRequestHeaders()
  • E、java.util.Enumeration getHeaderNames()

正确答案:E

第6题:

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

第7题:

A web application uses the HttpSession mechanism to determine if a user is “logged in”. When a user supplies a valid user name and password, an HttpSession is created for that user.  The user has access to the application for only 15 minutes after logging in. The code must determine how long the user has been logged in, and if this time is greater than 15 minutes, must destroy the HttpSession.  Which method in HttpSession is used to accomplish this?()

  • A、 getCreationTime
  • B、 invalidateAfter
  • C、 getLastAccessedTime
  • D、 getMaxInactiveInterval

正确答案:A

第8题:

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>

正确答案:A

第9题:

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.

正确答案:B,D,E

第10题:

Given this fragment from a Java EE deployment descriptor: 341. 342.java.lang.Throwable  343./mainError.jsp 344. 345. 346.java.lang.ClassCastException  347./castError.jsp 348. If the web application associated with the fragment above throws a ClassCastException.Which statement is true?()

  • A、The deployment descriptor is invalid.
  • B、The container invokes mainError.jsp.
  • C、The container invokes castError.jsp.
  • D、Neither mainError.jsp nor castError.jsp is invoked.

正确答案:C

更多相关问题