SCWCD(310-083)

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

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

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

第1题:

Given:10.publicvoidservice(ServletRequestrequest,11.ServletResponseresponse){12.ServletInputStreamsis=13.//insertcodehere14.}Whichretrievesthebinaryinputstreamonline13?()

A.request.getWriter();

B.request.getReader();

C.request.getInputStream();

D.request.getResourceAsStream();


参考答案:C

第2题:

Servlet的基本架构

public class ServletName extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

}

1、用String的方法将数据类型转换为String。


正确答案:

 

1、String.valueOf(1.23)

第3题:

下列哪个方法用于URL重写()

A、HttpServletResponse接口的rewriteURL()方法

B、HttpServlet接口的rewriteURL()方法

C、HttpServletRequest接口的encodeURL()方法

D、HttpServletResponse接口的encodeURL()方法


正确答案:D

第4题:

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

正确答案:A,C,D

第5题:

下面哪个方法不是HttpServlet类:()

  • A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOException
  • B、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • C、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • D、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

正确答案:D

第6题:

J2EE中,()类型的()方法用于得到会话。

A.HttpServletRequest、getSession

B.HttpServletResponse、newSession

C.HtttpSession、newInstance

D.HttpSession、getSession


正确答案:A

第7题:

Servlet可以通过以下哪个接口实现请求转发机制?()

  • A、HttpServletRequest接口
  • B、RequestDispatcher接口
  • C、HttpServletResponse接口
  • D、ServletConfig接口
  • E、Filter接口

正确答案:B

第8题:

给定某servlet 程序的片段,如下:

Public void doGet(HttpServletRequest

request,Httpservletresponse response)

{

_________

}

要把session的失效时间设为30分钟,应该在下划线处插入( )

A、request.getSession().setTimeout(1800);

B、request.getSession().setTimeout(30)

C、request.getSession().setMaxInactiveInterval(1800);

D、request.getSession().setMaxInactiveInterval(30);


正确答案:C

第9题:

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

第10题:

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)

正确答案:A,B

更多相关问题