Submit HTML5 form to Java JSP and get XML from Request InputStream

tarekahf 20-05-2016

I have developed complex program to submit PDF/XFA to server-side ASP.NET program.

I need now to do the same using Java server-side program.

The approach I am following is to break down the long and complex form into smaller sections. Each section will be a separate XDP form in HTML5 format, and it will have the following common buttons:

- Next

- Previous

- Jump to Section

- Save

- Complete

I am looking for a simple example to explain how to submit a HTML5 form to a Java server-side program (JSP or Servlet) and how to retrieve the submitted XML or the form fields and values.

I did some effort, but still need some help. Please download the basic HTML5 XDP form from here​. See snapshots below for more details. The code to submit is  placed under the "Save" button, click event:

    var theBtnSubmit = cmdSubmitForm.resolveNode("#event").submit;

    var theTarget = form_config.server_url.rawValue + "?" + "action=save" + "&form_id=" + form_config.form_id.rawValue + "&section_id=" + form_config.section_id.rawValue;

    theBtnSubmit.target = theTarget;

    cmdSubmitForm.execEvent("click");

The JSP is very simple. You can download it from here. I used the following lines of code to get the InputStream and convert to string:

ServletInputStream ris = request.getInputStream();

String theString = IOUtils.toString(ris);

I developed a simple Java program using JSP under a Dynamic Web Project.

The problem:

On the server, I am unable to retrieve the form fields and values in XML format. What I am getting is the concatenated values of the fields which are filled.

Tarek

953766_pastedImage_0.png

The hidden Submit Button "cmdSubmitForm:

953781_pastedImage_0.png

953772_pastedImage_12.png

953769_pastedImage_4.png

953773_pastedImage_16.png

Accepted Solutions (1)

Accepted Solutions (1)

tarekahf 07-06-2016

Finally, it worked. As a matter of fact, the above method is working fine. The only issue was that the string must be escaped for XML.

I add the following code, and I can now see the XML:

<%@page import="org.apache.commons.lang3.StringEscapeUtils" %>

...

String theString = IOUtils.toString(ris, Charset.forName("UTF-8"));

theString = StringEscapeUtils.escapeXml10(theString);

out.print("input stream in string format : " + theString + "<br/>");

Tarek

Answers (2)

Answers (2)

tarekahf 27-02-2017

Sorry Tussha for late reply.

As a matter of fact, we stopped working on HTML5 under Adobe LiveCycle due to many limitations we have faced when we developed a working prototype. We are rebuilding now all forms in pure HTML5/Angular (AngularJS)/Javascript/CSS/Bootstrap.

At this stage, I won't be able to provide any feedback on HTML5 implementation under Adobe LiveCycle since long time has passed already.

Tarek

Tusshar2603 20-11-2016

Hi Tarek,

Is there any way we can submit a form/fetch the xml from a HTML5 form, without using a hidden submit button?

Any help/sugestion is much appreciated.

-Tussha