网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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);


参考答案

参考解析
解析: 暂无解析
更多 “单选题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);” 相关考题
考题 Given:10.publicvoidservice(ServletRequestrequest,11.ServletResponseresponse){12.ServletInputStreamsis=13.//insertcodehere14.}Whichretrievesthebinaryinputstreamonline13?() A.request.getWriter();B.request.getReader();C.request.getInputStream();D.request.getResourceAsStream();

考题 Servlet的基本架构public class ServletName extends HttpServlet {public void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {}public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {}}1、用String的方法将数据类型转换为String。

考题 Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here 26.} Which should you insert at line 25 to properly invoke the next filter in the chain, or the target servlet if thereare no more filters?()A、chain.forward(request, response);B、chain.doFilter(request, response);C、request.forward(request, response);D、request.doFilter(request, response);

考题 Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in th epage being invoked?()A、 ErrorB、 ExceptionC、 ThrowableD、 Request errorE、 Request exception

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

考题 下列方法哪2个可以用来获取用户提交的表单(Form)参数()A、HttpServletRequest. getParameter(String)B、HttpServletRequest.getAttribute(String)C、HttpServletRequest.getParameterNames()D、HttpServletRequest.getAttributeNames()

考题 Given a header in an HTTP request:X-Retries:4 Which two retrieve the value of the header from a given HttpServletRequest request?()A、Request.getHeader("X-Retries")B、Request.getIntHeader("X-Retries")C、Request.getRequestHeader("X-Retries")D、Request.getHeaders("X-Retries").get(0)E、Request.getRequestHeaders("X-Retries").get(0)

考题 下面关于HttpServletRequest接口描述错误的是()A、HttpServletRequest接口中最常用的方法就是获得请求的参数B、JSP中的内建对象request是一个HttpServletRequest实例C、HttpServletRequest主要处理读取和写入HTTP头标D、HttpServletRequest主要处理取得路径信息和标识HTTP会话,取得和设置cookiesE、HttpServletRequest主要处理取得输入和输出流

考题 Given an HttpServletRequest request, which retrieves an object of type Account with an Id of “account”?()A、 Account account = request.get Resource(”account”):B、 Account account = request.get Attribute (“account”):C、 Account account = request.get Parameter (account”):D、 Account account = (Account)request.getResource (“account”):E、 Account account = (Account) request.get Attribute (“account”):F、 Account account = (Account) request.get Paramter (“account”):

考题 Given an HttpServletRequest request and HttpServletResponse response,which sets a cookie "username"with the value "joe" in a servlet?()A、request.addCookie("username", "joe")B、request.setCookie("username", "joe")C、response.addCookie("username", "joe")D、request.addHeader(new Cookie("username", "joe"))E、request.addCookie(new Cookie("username", "joe"))F、response.addCookie(new Cookie("username", "joe"))

考题 Given: 10.public void service(ServletRequest request, 11.ServletResponse response) { 12.ServletInputStream sis = 13.// insert code here 14.} Which retrieves the binary input stream on line 13?()A、request.getWriter();B、request.getReader();C、request.getInputStream();D、request.getResourceAsStream();

考题 Which retrieves all cookies sent in a given HttpSErvletRequest request?()A、 request.getCookies()B、 request.getAttributes()C、 request.getSession ().getCookies()D、 request.getSession (). GetAttributes()

考题 Given a header in an HTTP request: X-Retries:4  Which two retrieve the value of the header from a given ServletRequest request? ()A、 request.getHeader (“X-Retries”)B、 request.getIntHeader (“X-Retries”)C、 request.getRequestHeader (“x-Retries”)D、 request.getHeaders (“X-Retries”).get (0)E、 re request.getRequest Headers (“X-Retries”). Get (0)

考题 单选题Given an HttpServlet Request request and Http Servlet Response response, which sets a cookie “username” with the value “joe” in a servlet.?()A  request.add Cookie (“username”. “joe”)B  request.set Cookie (“username, “joe”)C  response.add Cookie (username”, “joe”))D  request.add Header (new Cookie (“username”, “joe”))E  request.add Cookie (new Cookie (“username”, “joe”))F  response.add Cookie (new Cookie (“username”, “joe”))G  response.add Header (new Cookie (“username”, “joe”))

考题 单选题Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()A response.setError(302);B response.sendError(302);C response.setStatus(302);D response.sendRedirect(302);E response.sendErrorRedirect(302);

考题 单选题Which retrieves all cookies sent in a given HttpSErvletRequest request?()A  request.getCookies()B  request.getAttributes()C  request.getSession ().getCookies()D  request.getSession (). GetAttributes()

考题 单选题在Java EE中,关于创建HttpServletRequest对象的说法正确的是()。A  从request获取传入的参数,可以调用getParameter方法B  由Java Web应用的Servlet或JSP组件负责创建,当Servlet或JSP组件响应HTTP请求时,先创建HttpServletRequest对象C  由程序员通过编码形式创建,以传递请求数据D  以上都不对

考题 单选题下面关于HttpServletRequest接口描述错误的是()A HttpServletRequest接口中最常用的方法就是获得请求的参数B JSP中的内建对象request是一个HttpServletRequest实例C HttpServletRequest主要处理读取和写入HTTP头标D HttpServletRequest主要处理取得路径信息和标识HTTP会话,取得和设置cookiesE HttpServletRequest主要处理取得输入和输出流

考题 单选题Given a JSP error page, which implicit object refers to the uncaught Throwable that resulted in th epage being invoked?()A  ErrorB  ExceptionC  ThrowableD  Request errorE  Request exception

考题 单选题Given an HttpServletRequest request and HttpServletResponse response,which sets a cookie "username"with the value "joe" in a servlet?()A request.addCookie(username, joe)B request.setCookie(username, joe)C response.addCookie(username, joe)D request.addHeader(new Cookie(username, joe))E request.addCookie(new Cookie(username, joe))F response.addCookie(new Cookie(username, joe))

考题 多选题Given a header in an HTTP request: X-Retries:4  Which two retrieve the value of the header from a given ServletRequest request? ()Arequest.getHeader (“X-Retries”)Brequest.getIntHeader (“X-Retries”)Crequest.getRequestHeader (“x-Retries”)Drequest.getHeaders (“X-Retries”).get (0)Ere request.getRequest Headers (“X-Retries”). Get (0)

考题 单选题Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()A chain.forward(request, response);B chain.doFilter(request, response);C request.forward(request, response);D request.doFilter(request, response);

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

考题 单选题Given an HttpServletRequest request, which retrieves an object of type Account with an Id of “account”?()A  Account account = request.get Resource(”account”):B  Account account = request.get Attribute (“account”):C  Account account = request.get Parameter (account”):D  Account account = (Account)request.getResource (“account”):E  Account account = (Account) request.get Attribute (“account”):F  Account account = (Account) request.get Paramter (“account”):

考题 多选题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);

考题 单选题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?()A An IllegalStateException is thrown at runtime.B An InvalidSessionException is thrown at runtime.C The string value=null appears in the response stream.D The string value=myAttributeValue appears in the response stream.

考题 多选题Given a header in an HTTP request:X-Retries:4 Which two retrieve the value of the header from a given HttpServletRequest request?()ARequest.getHeader(X-Retries)BRequest.getIntHeader(X-Retries)CRequest.getRequestHeader(X-Retries)DRequest.getHeaders(X-Retries).get(0)ERequest.getRequestHeaders(X-Retries).get(0)