Very good idea. What I've done is made a function which works with POST and
GET requests, and is used as follows :
<%
// Post request
Hashtable p = new Hashtable();
p.put("string", "backwards");
HttpForwardUtil.include(response, "POST",
"http://java.sun.com/cgi-bin/backwards", p);
// Get request
HttpForwardUtil.include(response, "GET", "http://www.yahoo.com", null);
%>
This is *almost* the functionality I'm looking for. When you do something
like this :
<B>This is my JSP file</B>
<jsp:forward page="http://someLOCALservlet">
<B>More JSP code</B>
the only thing that gets sent to the browser is the data from
http://someLOCALservlet, not the 2 other lines. So what I'm looking for is
if I type in :
<B>This is my JSP file</B>
<% HttpForwardUtil.forward(response, "GET", "http://www.yahoo.com", null);
%>
<B>More JSP code</B>
All I'll see is Yahoo. I tried putting a response.reset() before the call,
and a reponse.flushBuffer() after the call (thinking that it would commit
the call and send it) but I still get the other JSP code. I can work around
this easily using the include as opposed to the forward, but if anyone has
any input, that'd be great.
If there's anyone that could use this code please let me know personally,
and I can send it. It was a bit too long for the listserv.
Take it easy,
Roy
----- Original Message -----
From: "Geert Van Damme" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 03, 2001 2:31 AM
Subject: Re: Forwarding / Redirecting to external pages.
> Well, you could (rather easily) create a 'proxy' servlet.
> The servlet makes a URLConnection to the exernal page and passes the
> resulting data back to the original request.
> In this case, you can use forward(ServletRequest, ServletResponse) to
> redirect to the servlet.
>
> Get the idea?
>
> Geert Van Damme
>
> > -----Original Message-----
> > From: A mailing list about Java Server Pages specification and reference
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Fei Li
> > Sent: dinsdag 3 april 2001 4:14
> > To: [EMAIL PROTECTED]
> > Subject: Re: Forwarding / Redirecting to external pages.
> >
> >
> > Actually you need forward() but I do not know why you hang on
> > sendRedirect()
> > that is used to tell user the page location is changed.
> >
> > Use the following that works for both POST and GET and any.
> >
> > forward(ServletRequest, ServletResponse) - Method in interface
> > javax.servlet.RequestDispatcher
> > Forwards a request from a servlet to another resource (servlet,
> > JSP file, or
> > HTML file) on the server.
> >
> > forward(String) - Method in class javax.servlet.jsp.PageContext
> > This method is used to re-direct, or "forward" the current
ServletRequest
> > and ServletResponse to another active component in the application
> >
> > Fei Li
> >
> > -----Original Message-----
> > From: Roy Truelove [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, April 02, 2001 6:10 PM
> > To: [EMAIL PROTECTED]
> > Subject: Forwarding / Redirecting to external pages.
> >
> >
> > Hey everyone,
> >
> > I've done my research, and I've come up with the following
conclusion
> > (I'm hoping someone will tell me that I'm wrong!). It is not possible
to
> > redirect to an external page using a POST request. Here's what
> > makes me say
> > this. The HttpServletResponse.sendRedirect() method can only
> > sent via a GET
> > request, and can only use URL-encoded parameters. If the resource your
> > sending the request to expects POST parameters, then this is no good.
The
> > only other way is to use a RequestDispatcher, but this also
> > *might* not be a
> > POST request, and cannot be used for external resources, depending on
its
> > implimentation.
> >
> > Any ideas? Given the HTTP protocol, is it even possible to make a
browser
> > do this?
> >
> > Much thanks in advance,
> >
> > Roy Truelove
> > pulver.com
> >
> > ==================================================================
> > =========
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> > DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> > ==================================================================
> > =========
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > For digest: mailto [EMAIL PROTECTED] with body: "set
> > JSP-INTEREST DIGEST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets