send XML Request string using POST

M

Matt

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>
 
M

Martin Honnen

Matt said:
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.
 
G

GIMME

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;
}
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top