469,352 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

send XML Request string using POST

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>
Jul 20 '05 #1
2 10168


Matt wrote:
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>


I am not sure what the problem is, in page2.jsp you want to build an XML
request string and post it to another page?

If you expect the browser to build an XML request then you would neeed
XForms not HTML forms.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
You can create XML (a JDOM Element) right from the request object ...
<%@ page import="java.util.Enumeration"%>
<%@ page import="org.jdom.Element"%>
<%!

public Element Create( HttpServletRequest request )
{
Element command = new Element("xml_data");
Enumeration enum = request.getParameterNames();
while ( enum.hasMoreElements() ) {
String sKey = (String) enum.nextElement();
String [] temp = (String[]) request.getParameterValues(sKey);
int iLen = temp.length;
for ( int j=0 ; j < iLen ; j++ ){
String sVal = temp[j] ;
String sName = sKey;
command.addContent(new Element(sName).addContent(sVal));
}
}
return command;
}
%>
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by malborg | last post: by
2 posts views Thread by Fatih BOY | last post: by
1 post views Thread by khawar | last post: by
9 posts views Thread by eswanson | last post: by
3 posts views Thread by keith.schincke | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.