实现转发需要两个步骤,首先在Servlet中要得到RequestDispatcher对象,然后在调用该对象的forward方法实现转发。
实现转发需要两个步骤,首先在Servlet中要得到RequestDispatcher对象,然后在调用该对象的forward方法实现转发。
相关考题:
在J2EE中,在Servlet1中的doGet和doPost方法中只有如下代码:request.setAttribute(jb,aptech);response.sendRedirect(http://localhost:8080/servlet/Servlet2);那么在Servlet2中使用()可以把属性jb的值取出来。 A.Stringstr=request.getAttribute(jb);B.Stringstr=(String)request.getAttribute(jb);C.Objectstr=request.getAttribute(jb);D.取不出来
ServletAforwardedarequesttoservletBusingtheforwardmethodofRequestDispatcher.WhatattributeinB’srequestobjectcontainstheURIoftheoriginalrequestreceivedbyservletA?() A.REQUEST_URIB.javax.servlet.forward.request_uriC.javax.servlet.forward.REQUEST_URID.javax.servlet.request_dispatcher.request_uriE.javax.servlet.request_dispatcher.REQUEST_URI
在servlet中实现转发功能是通过()方法实现的。 A.response.getRequestDispatcher()B.response.sendRedirect()C.request..getRequestDispatcher()D.request.sendRedirect()
在servlet中实现重定向功能是通过()方法实现的。 A.response.getRequestDispatcher()B.response.sendRedirect()C.request..getRequestDispatcher()D.request.sendRedirect()
当属性scope的值为application时,JSP动作定义的JavaBean实例就会被存储到()对象中。A、Servlet ContextB、Http SessionC、Servlet ApplicationD、Http Servlet Request
Servlet可以通过以下哪个接口实现请求转发机制?()A、HttpServletRequest接口B、RequestDispatcher接口C、HttpServletResponse接口D、ServletConfig接口E、Filter接口
Servlet A forwarded a request to servlet B using the forward method of RequestDispatcher. What attributein B’s request object contains the URI of the original request received by servlet A?()A、REQUEST_URIB、javax.servlet.forward.request_uriC、javax.servlet.forward.REQUEST_URID、javax.servlet.request_dispatcher.request_uriE、javax.servlet.request_dispatcher.REQUEST_URI
在JSP中需要将1.jsp的请求数据通过2.jsp转发给3.jsp,应该在2.jsp中采用()方式实现。A、〈%request.sendRedirect(“3.jsp”)%〉B、〈%response.sendRedirect(“3.jsp”)%〉C、〈%request.getRequestDispatcher(“3.jsp”).forward(request,response)%〉D、〈%response.sentRedirect(“32.jsp”).forward(request,response)%〉
Servlet通过()可以实现请求转发机制。A、HttpServletRequest接口B、RequestDispatcher接口C、HttpServletResponse接口D、ServletConfig接口E、Filter接口
单选题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”))
单选题在JSP中需要将1.jsp的请求数据通过2.jsp转发给3.jsp,应该在2.jsp中采用()方式实现。A〈%request.sendRedirect(“3.jsp”)%〉B〈%response.sendRedirect(“3.jsp”)%〉C〈%request.getRequestDispatcher(“3.jsp”).forward(request,response)%〉D〈%response.sentRedirect(“32.jsp”).forward(request,response)%〉
单选题Servlet可以通过以下哪个接口实现请求转发机制?()AHttpServletRequest接口BRequestDispatcher接口CHttpServletResponse接口DServletConfig接口EFilter接口
单选题Servlet通过()可以实现请求转发机制。AHttpServletRequest接口BRequestDispatcher接口CHttpServletResponse接口DServletConfig接口EFilter接口
单选题Which retrieves the binary input stream on line 13?()A request.get Writer ():B request.get Reader ():C request.get Input Stream():D request.get Resource As Stream():E request.get Resource As Stream (Servlet Request. REQUEST):
单选题Servlet A receives a request that it forwards to servlet B within another web application in the same webcontainer. Servlet A needs to share data with servlet B and that data must not be visible to other servlets inA’s web application. In which object can the data that A shares with B be stored?()AHttpSessionBServletConfigCServletContextDHttpServletRequestEHttpServletResponse
单选题Servlet A forwarded a request to servlet B using the forward method of RequestDispatcher. What attributein B’s request object contains the URI of the original request received by servlet A?()AREQUEST_URIBjavax.servlet.forward.request_uriCjavax.servlet.forward.REQUEST_URIDjavax.servlet.request_dispatcher.request_uriEjavax.servlet.request_dispatcher.REQUEST_URI
单选题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?()ADispatcher view=context.getDispatcher(viewURL);view.forward Request(request, response);BDispatcher view=request.getDispatcher(viewURL);view.forward Request(request, response);CRequestDispatcher view. =context.getRequestDispatcher(viewURL);view.forward(request,response);DRequestDispatcher view=request.getRequestDispatcher(viewURL);view.forward(request, response);
单选题在J2EE中,Servlet1的代码如下: import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Servlet1 extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String aa=request.getQueryString(); String bb=request.getMethod(); out.println(aa); out.println(bb); } } 把Servlet1.class文件放在Web服务器适合的目录下,在浏览B器地址栏内输入:http://localhost:8080/servlet/Servlet1?name=jb-aptechphone=12345678,看到的结果是()。Aname=jb-aptechphone=12345678 GETBname=jb-aptech,phone=12345678 GETCjb-aptech,12345678 POSTDname,phone GETE2,POST
判断题重定向仅仅是将用户定向到其他的JSP页面或Servlet,而不能将Request对象转发给所指向的资源。A对B错