want to generate a html form page with dynamic data and submit this form to a url
Hi friends,
I am having an applet, and it has a button(say submit) to extract some dynamic data from backend system and generate a html form page with this data and then open the this newly created html form and submit it to the url mentioned in the form.
Can anyone suggest me how I can do this.
My html page file content is as below shown:
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM id='JCLCreateLetter' name='JCLCreateLetter' action='http://20.17.17.146:9080/CCM/NBPIPostInputHandler' method='post'>
<Input Type='hidden' id='BPI' name='BPI' value='CV_PEK_online_no_comp'>
<Input Type='hidden' id='groupName' NAME='GROUPNAME' VALUE='CV_PEK_Online'>
<Input Type='hidden' id='userName' name='userName' value='CV_PEK'>
<Input Type='hidden' id='role' name='role' value='CV_PEK_online_pgm'>
<Input Type='hidden' id='xmlRecords' name='xmlRecords' value='<Record01><CompanyId>PEK</CompanyId><CnvLetterId> </CnvLetterId><AlphaProcessDte>JUNE 24, 2009</AlphaProcessDte></Record01>'</FORM>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
document.forms["JCLCreateLetter"].submit()
-->
</script>
</BODY>
</HTML>
A servlet to serve the content
Hi Vishal
Just some thoughts.
Will it not be easier to set up a servlet to serve the HTML you have in a string.
Set up a servlet and give it a URL.
Then use the Applet api to open the URL.
If however this is not possible; then the applet needs to be signed and a policy file generated. Here's a quick tutorial from Sun
java.sun.com/docs/books/tutorial/security/tour1/index.html
Thanks
Javascript Applet communication
Another way to achieve the same thing is through javascript.
You need to expose your string using a public getter method
say
Quote:
public String getHTMLString(){
return HTMLString //return your HTML String
}
Now when you are embedding your applet you can get the HTML String using scripting see :
java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/js_java.html
or search for "javascript to java communication" or "scripting applets"
After you get a handle to string you can use document.write function to embed that HTMLString in the page and submit the form after that.
Hope this view point helps