I wonder if we can send XML request string using HTTP POST protocol?
The JSP page needs to send XML request string to another JSP page when the
user clicks submit button, I wonder how to get started because when user
click submit button, it will send the form to page2.jsp.
<form action="page2.jsp" method="POST">
Name: <input type="text" name="fname">
//etc.. controls
<input type="submit">
</form>
-
send XML request string using HTTP POST protocol? (5 messages)
- Posted by: Raymond Lee
- Posted on: April 21 2004 01:02 EDT
Threaded Messages (5)
- send XML request string using HTTP POST protocol? by Paul Strack on April 21 2004 10:35 EDT
- send XML request string using HTTP POST protocol? by Raymond Lee on April 21 2004 12:01 EDT
-
send XML request string using HTTP POST protocol? by Paul Strack on April 21 2004 05:45 EDT
-
send XML request string using HTTP POST protocol? by Raymond Lee on April 21 2004 10:14 EDT
- send XML request string using HTTP POST protocol? by Paul Strack on April 22 2004 10:39 EDT
-
send XML request string using HTTP POST protocol? by Raymond Lee on April 21 2004 10:14 EDT
-
send XML request string using HTTP POST protocol? by Paul Strack on April 21 2004 05:45 EDT
- send XML request string using HTTP POST protocol? by Raymond Lee on April 21 2004 12:01 EDT
-
send XML request string using HTTP POST protocol?[ Go to top ]
- Posted by: Paul Strack
- Posted on: April 21 2004 10:35 EDT
- in response to Raymond Lee
Define a hidden form field to hold your XML data.
<form action="page2.jsp" method="POST">
<input type="hidden" name="xmldata">
Name: <input type="text" name="fname">
//etc.. controls
<input type="submit" onsubmit="populate_xmldata()">
</form>
Write a JavaScript function [populate_xmldata()] that reads the rest of your form data, creates an XML string and stores it in the xmldata field when the form is submitted.
In your receiving JSP (page2.jsp), retrieve the XML data from the xmldata parameter:
<% String xmldata = request.getParameter("xmldata"); %> -
send XML request string using HTTP POST protocol?[ Go to top ]
- Posted by: Raymond Lee
- Posted on: April 21 2004 12:01 EDT
- in response to Paul Strack
Thanks.
Is it possible just selectively send hidden field "xmldata" when the user click the submit button, instead of submitting all the form control values? Since page2.jsp only cares about field "xmldata." -
send XML request string using HTTP POST protocol?[ Go to top ]
- Posted by: Paul Strack
- Posted on: April 21 2004 17:45 EDT
- in response to Raymond Lee
Thanks. Is it possible just selectively send hidden field "xmldata" when the user click the submit button, instead of submitting all the form control values? Since page2.jsp only cares about field "xmldata."
In theory yes. To do this, you would have to create a completely separate hidden HTML form. When the user submitted the visible HTML form, you would have to cancel that form submission, transfer the data to the hidden form, and submit that instead.
Since the target JSP will ignore any extraneous data, I doubt this is worth all the trouble. -
send XML request string using HTTP POST protocol?[ Go to top ]
- Posted by: Raymond Lee
- Posted on: April 21 2004 22:14 EDT
- in response to Paul Strack
Given XSD (xml schema), how to transform the form data to xml string? -
send XML request string using HTTP POST protocol?[ Go to top ]
- Posted by: Paul Strack
- Posted on: April 22 2004 10:39 EDT
- in response to Raymond Lee
JavaScript does not have any support for XML Schema. The easiest thing to do is perform the transformation manually:
var xml = "<root>";
xml += "<field1>" + document.theForm.field1.value + "</field1>";
xml += "<field2>" + document.theForm.field2.value + "</field2>";
...
xml += "</root>";