Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2009, 12:02 PM
Member
 
Join Date: Jul 2009
Location: India
Posts: 5
Rep Power: 0
vishalkrsrivastava is on a distinguished road
Default 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>
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-16-2009, 04:57 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 585
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
send the piece of code what u have written ,so that we can help u to proceed.
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-17-2009, 11:02 AM
Member
 
Join Date: Jul 2009
Location: India
Posts: 5
Rep Power: 0
vishalkrsrivastava is on a distinguished road
Default
the complete html code shown above is stored in a String object.
I do not have any idea of how I can write this String to a file on the fly without storing it any where and then open this html file(since I do not to store the file on the user's m/c and its not possible to write it on server without using any server side code.)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-17-2009, 12:10 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 585
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi Vishal,
You take a Stringbuffer and push all the string.Finally write the content of StringBuffer to the file object .Gothru I/O tutorial.

Ex:

1.Append the String to StringBuffer object.
2.Finally convert the StringBuffer to String and write to a file.

Ex:
StringBuffer sb = new StringBuffer();
sb.append(".....Ur html contents");

FileWriter fstream = new FileWriter(new File("test.htm"));
BufferedWriter out = new BufferedWriter(fstream);
out.write(sb.toString().trim());
__________________
Ramya

Last edited by RamyaSivakanth; 07-17-2009 at 12:13 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-20-2009, 08:53 PM
Member
 
Join Date: Jul 2009
Location: India
Posts: 5
Rep Power: 0
vishalkrsrivastava is on a distinguished road
Default
Hi,

I am having an applet application. From applet you can not write and save a file on a server.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-21-2009, 02:24 PM
Member
 
Join Date: Jul 2009
Location: India
Posts: 5
Rep Power: 0
vishalkrsrivastava is on a distinguished road
Default
can you suggest something by which I can write the file to server or launch the page by passing the String variable to javascript or something.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-21-2009, 02:39 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 585
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi Vishal,
Gothru this link which help u a lot.

Creating a Trusted Applet with Local File System Access Rights
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 08-12-2009, 11:16 AM
Member
 
Join Date: Jul 2009
Location: India
Posts: 5
Rep Power: 0
vishalkrsrivastava is on a distinguished road
Default
Is there any other way to do ?

I tried signing my applet but somehow its not working.
During signing do we have any step to grant read write permission to certain set of files.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 08-12-2009, 03:03 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 585
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi Vishal,
Check whether this below link helps you.

JDL Based Applets and File Access
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 08-12-2009, 04:14 PM
Member
 
Join Date: Aug 2009
Posts: 2
Rep Power: 0
vidurNigam is on a distinguished road
Default 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
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 08-12-2009, 05:02 PM
Member
 
Join Date: Aug 2009
Posts: 2
Rep Power: 0
vidurNigam is on a distinguished road
Default 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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use one form to submit data to 2 tables on mysql kwesiaryee New To Java 2 10-10-2008 02:41 PM
enctype=multipart/form-data with form data in struts vk_satheesh New To Java 0 09-19-2008 01:48 PM
how to search xml file data based on the given keyword from html form? nicemothi XML 0 04-04-2008 10:36 AM
Generate XML request from web form sabatier XML 1 08-09-2007 08:53 PM
how to upload a file along with html form data pranith Java Servlet 3 07-30-2007 03:33 AM


All times are GMT +2. The time now is 11:43 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org