John Cartwright wrote:
> Hello All,
>
> I would like to find a way to have my servlet call an arbitrary URL
> (e.g. a cgi, servlet in another context, or even a URL on a different
> host). I don't seem to be able to do this with:
> rd = getServletContext().getRequestDispatcher(url);
>
> It will only let me forward to pages/servlets in the same context.
>
> I am using Tomcat 3.1, and would greatly appreciate any suggestions.
>
You can use HttpServletResponse.sendRedirect() for this. It sends a "redirect"
response back to your browser, which will then link to the new URL that you pass as
an argument -- which can be any URL on any server.
NOTE: You (obviously) won't be able to share any request attributes or session
attributes with the new URL since sendRedirect causes the browser to send a second
request, and sessions are scoped to the same context just like RequestDispatchers
are.
> -- john
Craig McClanahan
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00): Sun Technical Briefing
Session T06 (24-Oct 14h00-15h00): Migrating Apache JServ
Applications to Tomcat
___________________________________________________________________________
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