This may be a silly question, but is it possible to issue
a POST request from a JSP page to a servlet running on the
same server IN THE SAME SESSION as the JSP page?

My JSP displays a form on a GET, and is also the target
when the form is submitted (POST).  In the POST handler, I
want to create an XML document from the form fields, then
issue a POST back to the servlet that controls the application
IN THE SAME SESSION that the JSP is running in.   However, I'm
not sure how to accomplish this.  I am using response.encodeUrl
to encode the servlet URL, but this didn't help.  Here is the
code I'm using in my JSP POST handler:

...
String urlString = (String)session.getValue("register.url");
...
HttpURLConnection       conn;
Writer                  o;
URL                     url = new URL(urlString + "?op=batch");

urlString = response.encodeUrl(urlString);
System.out.println("After encoding URL: " + urlString);

conn = (HttpURLConnection) url.openConnection ();
conn.setDoOutput (true);
conn.setUseCaches (false);
conn.setRequestMethod("POST");
conn.setRequestProperty ("Content-Type", "text/xml;charset=UTF-8");

o = new OutputStreamWriter (conn.getOutputStream (), "UTF8");
o.write(...);
...
o.flush ();
o.close ();   // ESSENTIAL!
System.out.println("After output stream close");
...

Is there a way to stuff the current session object into the new
HttpURLConnection
object?  Or, is this a silly thing to attempt to do?

    -- Bill

--
Bill O'Keefe                                     [EMAIL PROTECTED]
Open Market, Inc.                            http://www.openmarket.com/
One Wayside Road                                 TEL: 781.359.7296
Burlington, MA 01803                             FAX: 781.359.8200

___________________________________________________________________________
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