单选题Given that session is a valid HttpSession object:   Int max = session.getAttribute(“MyReallyLongName”);   Which is true?()A The value returned needs to be cast to an int.B The getAttribute methos takes two arguments.C Primitive CANNOT be stored in the HttpSession.D The HttpSession attribute name must NOT exceed eight characters.

单选题
Given that session is a valid HttpSession object:   Int max = session.getAttribute(“MyReallyLongName”);   Which is true?()
A

 The value returned needs to be cast to an int.

B

 The getAttribute methos takes two arguments.

C

 Primitive CANNOT be stored in the HttpSession.

D

 The HttpSession attribute name must NOT exceed eight characters.


参考解析

解析: 暂无解析

相关考题:

要在session对象中保存属性,可以使用session.getAttribute("key","value")语句。() 此题为判断题(对,错)。

GiventhatsessionisavalidHttpSessionobject:Intmax=session.getAttribute(MyReallyLongName”);Whichistrue?() A.Thevaluereturnedneedstobecasttoanint.B.ThegetAttributemethostakestwoarguments.C.PrimitiveCANNOTbestoredintheHttpSession.D.TheHttpSessionattributenamemustNOTexceedeightcharacters.

Which two are true?() A.A finalizer may NOT be invoked explicitly.B.The finalize method declared in class Object takes no action.C.super.finalize()is called implicitly by any over riding finalize method.D.The finalize method for a given objec twill be called no more than once by the garbage collector.E.The order in which finalize will be called on two objects is based on the order in which the two objects became finalizable.

以下()可用于检索session属性userid的值。A、session.getAttribute(“userid”)B、session.setAttribute(“userid”)C、request.getParameter(“userid”)D、request.getAttribute(“userid”)

下列操作Session时,代码错误的是()A、HttpSession session=request.getSession(true);B、Session session=new Session();C、session.setAttribute("username","admin");D、String username=(String)session.getAttribute("username");E、response.add Session(Session);

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");

Given: 6. 7.%="processing" % 8. and a custom tag handler for foo which extends TagSupport. Which two are true about thetag handler referenced by foo?()A、The doStartTag method is called once.B、The doAfterBody method is NOT called.C、The EVAL_PAGE constant is a valid return value for the doEndTag method.D、The SKIP_PAGE constant is a valid return value for the doStartTag method.E、The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.

Given: 6.% int[] nums = {42, 420, 4200}; 7.request.setAttribute("foo", nums); % Which two successfully translate and result in a value of true?()A、${true or false}B、${requestScope[foo][0]  500}C、${requestScope[’foo’][1] = 420}D、${(requestScope[’foo’][0] lt 50)  (3 gt 2)}

You need to store a floating point number,called Tsquare,in the session scope. Which two code snippetsallow you to retrieve this value?()A、float Tsquare = session.getFloatAttribute("Tsquare");B、float Tsquare = (Float) session.getAttribute("Tsquare");C、float Tsquare = (float) session.getNumericAttribute("Tsquare");D、float Tsquare = ((Float) session.getAttribute.("Tsquare")).floatValue();E、float Tsquare = ((Float) session.getFloatAttribute.("Tsquare")).floatValue;

Given an HttpServletRequest request: 22.String id = request.getParameter("jsessionid"); 23.// insert code here 24.String name = (String) session.getAttribute("name"); Which three can be placed at line 23 to retrieve anexisting HttpSession object?()A、HttpSession session = request.getSession();B、HttpSession session = request.getSession(id);C、HttpSession session = request.getSession(true);D、HttpSession session = request.getSession(false);E、HttpSession session = request.getSession("jsessionid");

Upon a user’s first visit to the website, which two operations are always performed when the getSession method is called with no arguments in a servlet?()A、 All URLs returned by the server are rewritten.B、 An HttpSession object is created if necessary.C、 The user name and password of the user are checked.D、 The session ID is stored in the HTTP response as a cookie.

下面哪个方法可使session无效() A、session.setAttribute()B、session.getAttribute()C、session.invalidate()D、session.removeAttribute()

在Servlet里,能正确获取session的语句是()。A、HttpSession session=request.getSession(true)B、HttpSession session=request.getHttpSession(true)C、HttpSession session=response.getSession(true)D、HttpSession session=response.getHttpSession(true)

要在session对象中保存属性,可以使用以下哪个语句?()A、session.getAttribute(“key”,”value”)B、session.setAttribute(“key”,”value”)C、session.setAtrribute(“key”)D、session.getAttribute(“key”)

Which HttpSession method stores an object in a session?()A、 put(String name. Object value)B、 set(String name. Object value)C、 setAttribute(String name. Object value)D、 putAttribute(String name. Object value)E、 addAttribute(String name. Object value)

Given that session is a valid HttpSession object:   Int max = session.getAttribute(“MyReallyLongName”);   Which is true?()  A、 The value returned needs to be cast to an int.B、 The getAttribute methos takes two arguments.C、 Primitive CANNOT be stored in the HttpSession.D、 The HttpSession attribute name must NOT exceed eight characters.

Which statement is true?()A、A class’s finalize() method CANNOT be invoked explicitly.B、super.finalize() is called implicitly by any overriding finalize() method.C、The finalize() method for a given object is called no more than once by the garbage collector.D、The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

多选题下列操作Session时,代码错误的是()AHttpSession session=request.getSession(true);BSession session=new Session();Csession.setAttribute(username,admin);DString username=(String)session.getAttribute(username);Eresponse.add Session(Session);

单选题Which statement is true?()AA class’s finalize() method CANNOT be invoked explicitly.Bsuper.finalize() is called implicitly by any overriding finalize() method.CThe finalize() method for a given object is called no more than once by the garbage collector.DThe order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

单选题Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()AAn IllegalStateException is thrown at runtime.BAn InvalidSessionException is thrown at runtime.CThe string value=null appears in the response stream.DThe string value=myAttributeValue appears in the response stream.

多选题Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()AThe foo initialization parameter CANNOT be set programmatically.BCompilation fails because getInitParameter returns type Object.CThe foo initialization parameter is NOT a servlet initialization parameter.DCompilation fails because ServletContext does NOT have a getInitParameter method.EThe foo parameter must be defined within the  element of the deployment descriptor.

单选题Which HttpSession method stores an object in a session?()A put(String name. Object value)B set(String name. Object value)C setAttribute(String name. Object value)D putAttribute(String name. Object value)E addAttribute(String name. Object value)

多选题Upon a user’s first visit to the website, which two operations are always performed when the getSession method is called with no arguments in a servlet?()AAll URLs returned by the server are rewritten.BAn HttpSession object is created if necessary.CThe user name and password of the user are checked.DThe session ID is stored in the HTTP response as a cookie.

多选题Given an HttpServletRequest request: 22.String id = request.getParameter("jsessionid"); 23.// insert code here 24.String name = (String) session.getAttribute("name"); Which three can be placed at line 23 to retrieve anexisting HttpSession object?()AHttpSession session = request.getSession();BHttpSession session = request.getSession(id);CHttpSession session = request.getSession(true);DHttpSession session = request.getSession(false);EHttpSession session = request.getSession(jsessionid);

多选题Assume session is an HttpSession, and is not referenced anywhere else in ServletA. Which two changes, taken together, ensure that value is equal to “Hello” on line 23? ()AABBCCDDEE

多选题Given: 6. 7. 8. and a custom tag handler for foo which extends TagSupport. Which two are true about thetag handler referenced by foo?()AThe doStartTag method is called once.BThe doAfterBody method is NOT called.CThe EVAL_PAGE constant is a valid return value for the doEndTag method.DThe SKIP_PAGE constant is a valid return value for the doStartTag method.EThe EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.

多选题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?()AObject o = pageContext.getAttribute(foo);BObject o = pageContext.findAttribute(foo);CObject o = pageContext.getAttribute(foo,PageContext.SESSION_SCOPE);DHttpSession s = pageContext.getSession();Object o = s.getAttribute(foo);