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


相似考题
更多“单选题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”相关问题
  • 第1题:

    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

  • 第2题:

    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

  • 第3题:

    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

  • 第4题:

    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

  • 第5题:

    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()

    • A、<% if ( request.getSession(false) == null ) {// special processing} %>
    • B、<% if ( request.getHttpSession(false) == null ) {// special processing} %>
    • C、<% if ( requestObject.getSession(false) == null ) { // special processing} %>
    • D、<% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>

    正确答案:A

  • 第6题:

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


    正确答案: D
    解析: 暂无解析

  • 第7题:

    单选题
    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
    解析: 暂无解析

  • 第8题:

    多选题
    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,C
    解析: 暂无解析

  • 第9题:

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


    正确答案: C
    解析: 暂无解析

  • 第10题:

    单选题
    You are building a Front Controller using a JSP page and you need to determine if the user’s session hasNOT been created yet and perform some special processing for this case. Which scriptlet code snippet willperform this test?()
    A

    <% if ( request.getSession(false) == null ) {// special processing} %>

    B

    <% if ( request.getHttpSession(false) == null ) {// special processing} %>

    C

    <% if ( requestObject.getSession(false) == null ) { // special processing} %>

    D

    <% if ( requestObject.getHttpSession(false) == null ) { // special processing} %>


    正确答案: A
    解析: 暂无解析

  • 第11题:

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


    正确答案: C
    解析: 暂无解析

  • 第12题:

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


    正确答案: B
    解析: 暂无解析

  • 第13题:

    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

  • 第14题:

    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

  • 第15题:

    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

  • 第16题:

    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 in the servlet to the JSP for view generation.This information must NOT be accessible to any other servlet,JSP or session in the webapp. Which two techniques can you use to accomplish this goal?()

    • A、Add attributes to the session object.
    • B、Add attributes on the request object.
    • C、Add parameters to the request object.
    • D、Use the pageContext object to add request attributes.
    • E、Add parameters to the JSP’s URL when generating the request dispatcher.

    正确答案:B,E

  • 第17题:

    TestKing.com has a SQL Server 2005 computer. You have been assigned the task of retrieving information about a user who is currently logged in. You need to create a function that returns scalar information about the activity time for a particular user. What are two possible ways to achieve this goal?()

    • A、Create a function that returns a list of values that represent the login times for the given user.
    • B、Create a function that returns a list of values that represent the people who have logged more hours than the current user has logged.
    • C、Create a function that returns a numeric value that represents the number of hours that a user has logged for the current day.
    • D、Create a function that returns a numeric value that represents the number of hours that a user has logged for the current month.

    正确答案:C,D

  • 第18题:

    单选题
    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
    解析: 暂无解析

  • 第19题:

    单选题
    108- Conversation 2 How many times has the woman been sailing before?    
    A

    Never

    B

    Once

    C

    Twice


    正确答案: A
    解析: 对话中男士问道”Have you been sailing before”,女士给予了否定回答,可见她从来没有去航行过。

  • 第20题:

    单选题
    You are configuring the data source for an Oracle database. You will need to specify a test table for WebLogic to test the status of the database. Which option should you choose?()
    A

    a table name which has 100s of records

    B

    a table name which has 10s of records

    C

    a table name which has empty records

    D

    a table name which has 1000s of records

    E

    never use a table name


    正确答案: D
    解析: 暂无解析

  • 第21题:

    多选题
    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 in the servlet to the JSP for view generation.This information must NOT be accessible to any other servlet,JSP or session in the webapp. Which two techniques can you use to accomplish this goal?()
    A

    Add attributes to the session object.

    B

    Add attributes on the request object.

    C

    Add parameters to the request object.

    D

    Use the pageContext object to add request attributes.

    E

    Add parameters to the JSP’s URL when generating the request dispatcher.


    正确答案: E,A
    解析: 暂无解析

  • 第22题:

    单选题
    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
    解析: 暂无解析

  • 第23题:

    单选题
    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
    解析: 暂无解析