ServletContext context = getServletContext();
RequestDispatcher dispatcher =
context.getRequestDispatcher("/myDir/myJsppage.jsp"); // or servlet or html
page or whatever
dispatcher.forward(req,res);

A D C O R E - Digital Business Creators
Norrlandsgatan 10, SE-901 90 Umeå,Sweden
+46 (0)90 14 33 53  (office)
+46 (0)70 341 53 69 (mobile)
mailto:[EMAIL PROTECTED]
http://www.adcore.com


-----Original Message-----
From: Oscar Pérez [mailto:[EMAIL PROTECTED]]
Sent: den 28 februari 2001 12:13
To: [EMAIL PROTECTED]
Subject: Re: fordward servlets


How do I set the servlet target with
RequestDispatcher.forward(request,response)?


At 10.37 28/2/01 +0000, you wrote:
>sendRedirect(URL) sends a header back to the browser that tells it load
>from a new page
>the URL. Therefore the original request and response is lost to the next
>page URL.
>
>Where the request dispatcher insteads invokes the new page directly and if
>it is
>a servlet passes the request and response objects onwards. The browser
never
>knows what there was a transfer from one servlet to another.
>
>Caveat: Request dispatch only works on inside one web application.
>That is
>
>      localhost:8080/app1/servlet/ThisServlet
>
>cannot request dispatch to
>
>      localhost:8080/app2/servlet/AnotherServlet
>
>So if you want to do that between web applications (and different machines)
>you have to use `request.sendRedirect(URL)'.
>--
>Peter Pilgrim
>G.O.A.T
>                     "the Greatest Of All Time"
>
>
>
>---------------------------------------- Message History
>----------------------------------------
>
>
>From: Kyle Burke <[EMAIL PROTECTED]>@java.sun.com> on 28/02/2001 00:54
EST
>
>Please respond to "A mailing list for discussion about Sun Microsystem's
>Java              Servlet API Technology." <[EMAIL PROTECTED]>
>
>DELEGATED - Sent by:     "A mailing list for discussion about Sun
>Microsystem's Java              Servlet API Technology."@java.sun.com>
>
>
>To:   [EMAIL PROTECTED]
>cc:
>Subject:  Re: fordward servlets
>
>
>Although this will work just fine, it is less elegant than Robert's
solution
>of "RequestDispatcher.forward(request,response)".
>
>I have always used "response.sendRedirect(URL)" when some sort of error
>occurs within the currently executing Servlet.
>
>Can anyone shed some more light on this topic?  Do we even have access to
>'req' and 'res' the objects with "sendRedirect(URL)" or are they out of
>scope?  Suppose I'll test it.
>--<CUT>--
>
>
>--
>
>This e-mail may contain confidential and/or privileged information. If you
>are not the intended recipient (or have received this e-mail in error)
>please notify the sender immediately and destroy this e-mail. Any
>unauthorised copying, disclosure or distribution of the material in this
>e-mail is strictly forbidden.
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to