单选题Given an HttpServletRequest request and HttpServletResponse response,which sets a cookie "username"with the value "joe" in a servlet?()Arequest.addCookie(username, joe)Brequest.setCookie(username, joe)Cresponse.addCookie(username, joe)Drequest.addHeader(new Cookie(username, joe))Erequest.addCookie(new Cookie(username, joe))Fresponse.addCookie(new Cookie(username, joe))

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


参考解析

解析: 暂无解析

相关考题:

下列哪个方法用于URL重写() A、HttpServletResponse接口的rewriteURL()方法B、HttpServlet接口的rewriteURL()方法C、HttpServletRequest接口的encodeURL()方法D、HttpServletResponse接口的encodeURL()方法

给定某servlet 程序的片段,如下:Public void doGet(HttpServletRequestrequest,Httpservletresponse response){_________}要把session的失效时间设为30分钟,应该在下划线处插入( )A、request.getSession().setTimeout(1800);B、request.getSession().setTimeout(30)C、request.getSession().setMaxInactiveInterval(1800);D、request.getSession().setMaxInactiveInterval(30);

Given:10.publicvoidservice(ServletRequestrequest,11.ServletResponseresponse){12.ServletInputStreamsis=13.//insertcodehere14.}Whichretrievesthebinaryinputstreamonline13?() A.request.getWriter();B.request.getReader();C.request.getInputStream();D.request.getResourceAsStream();

J2EE中,()类型的()方法用于得到会话。 A.HttpServletRequest、getSessionB.HttpServletResponse、newSessionC.HtttpSession、newInstanceD.HttpSession、getSession

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。

Servlet可以通过以下哪个接口实现请求转发机制?()A、HttpServletRequest接口B、RequestDispatcher接口C、HttpServletResponse接口D、ServletConfig接口E、Filter接口

下面哪个方法不是HttpServlet类:()A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOExceptionB、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOExceptionC、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOExceptionD、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

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

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)

Servlet通过()可以实现请求转发机制。A、HttpServletRequest接口B、RequestDispatcher接口C、HttpServletResponse接口D、ServletConfig接口E、Filter接口

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

有关HttpServletRequest对象和HttpServletResponse对象的基本概念错误的是()。A、HttpServletRequest对象封装客户的请求信息,这些信息包括客户的环境信息和从客户端送到服务器端的数据B、HttpServletRequest类包含了从请求对象中抽取信息的一系列方法C、HttpServletResponse对象封装了动态产生的响应。例如,一个返回给客户端的HTML页面,这个HTML页面一般是由来自HttpServletResquest对象的数据构成的D、一个响应对象只能是HTML页面或者一个Servlet

sendRedirect和Forward机制的区别主要在于()。A、sendRedirect发送状态码给客户端浏览器B、sendRedirect丢失HttpServletRequest对象C、forward发送请求给其他Web资源时,不使用客户端浏览器D、forward传送HttpServletRequest和HttpServletResponse对象给其他Web资源

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: 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?()Aresponse.setError(302);Bresponse.sendError(302);Cresponse.setStatus(302);Dresponse.sendRedirect(302);Eresponse.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()

单选题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?()Arequest.addCookie(username, joe)Brequest.setCookie(username, joe)Cresponse.addCookie(username, joe)Drequest.addHeader(new Cookie(username, joe))Erequest.addCookie(new Cookie(username, joe))Fresponse.addCookie(new Cookie(username, joe))

单选题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 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?()Asession = response.getSession();Bsession = request.getSession();Csession = request.getSession(true);Dsession = request.getSession(false);Esession = request.getSession(jsessionid);

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