Consider the following approaches:
1) Post the form to a bean which will receive the posted data then do the
sendRedirect
2) Within the JSP page write some scripting to forward the posted data to
the desired destination and then retrieve the data from the input stream to
the redirected page. Remember the default scripting language used in the JSP
page is Java. Therefore you can take advantage of Java giving you the
ability to read from and write to a java.net.URLConnection. Let me know if
this is what you were looking for.

For example:
<HTML>
<BODY>
<%-- Comment Scriptlet for import statements --%>
<%@ page language="java" %>
<%@ page import="java.net.*" %>
<%@ page import="java.io.*" %>

<%-- Comment Scriptlet to get the parameters --%>
<%! String name, address, phone; %>
<%! String inputLine; %>
<%
        name = request.getParameter("name");
        address = request.getParameter("address");
        phone = request.getParameter("phone");

        <%-- Comment create URL adding posted information as parameters to
the servlet
             the destination URL can be anywhere. note:  this does not
handle any parameters
           containing spaces. for example, if the address is 555 Road then
the proper way to
           send this parameter would be &address=555+Road&phone=777.323.8888
--%>

        StringBuffer url = new
StringBuffer("http://localhost:8080/ServRoot/RedirectServlet?name=");
        url.append(name);
        url.append("&address=");
        url.append(addresss);
        url.append("&phone=");
        url.append(phone);

     try{
        URL redirectURL = new URL(url.toString());
        URLConnection connection = redirectURL.openConnection();
        connection.setDoOutput(true);

        <%-- Comment get inputstream from the url connection to read data
returned from the
             requested URL i.e servlet or html. --%>
        BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));

        while((inputLine = in.readLine()) != null)
        {
%>
        <B><%=inputLine %></B>
<%
        }

                in.close();
        }catch(Exception e) {
%>
        <H3><%=e.toString() %></H3>
<%
        }
%>

</BODY>
</HTML>




-----Original Message-----
From: Bragg, Casey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 23, 2000 1:46 PM
To: [EMAIL PROTECTED]
Subject: Forwarding POSTed data


Consider the following :
   1) User fills out an HTML form
   2) The form is POSTed to JSP page A
   3) That JSP page makes a decision to forward the posted request to a URL
on a different server (The 'different server' part is the key).  The
destination URL could be anything from an HTML page to a servlet to
whatever.  The nature of the destination cannot be relevant to the solution.


Anyone know how to accomplish the forward in step 3?  jsp:forward only works
with destinations within the originating servletcontext.  I can have an
associated bean do a sendRedirect to the destination, but the posted data is
apparently not forwarded.

I'm going nowhere fast... Your help is greatly appreciated!

Thanks...

...Casey

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
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".
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

Reply via email to