Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    5
    Rep Power
    0

    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>

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    send the piece of code what u have written ,so that we can help u to proceed.
    Ramya:cool:

  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    5
    Rep Power
    0

    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.)

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    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());
    Last edited by RamyaSivakanth; 07-17-2009 at 11:13 AM.
    Ramya:cool:

  5. #5
    Join Date
    Jul 2009
    Location
    India
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    I am having an applet application. From applet you can not write and save a file on a server.

  6. #6
    Join Date
    Jul 2009
    Location
    India
    Posts
    5
    Rep Power
    0

    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.

  7. #7
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    Hi Vishal,
    Gothru this link which help u a lot.

    Creating a Trusted Applet with Local File System Access Rights
    Ramya:cool:

  8. #8
    Join Date
    Jul 2009
    Location
    India
    Posts
    5
    Rep Power
    0

    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.

  9. #9
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    Hi Vishal,
    Check whether this below link helps you.

    JDL Based Applets and File Access
    Ramya:cool:

  10. #10
    vidurNigam is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    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

  11. #11
    vidurNigam is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

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

Similar Threads

  1. How to use one form to submit data to 2 tables on mysql
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 10-10-2008, 01:41 PM
  2. enctype=multipart/form-data with form data in struts
    By vk_satheesh in forum New To Java
    Replies: 0
    Last Post: 09-19-2008, 12:48 PM
  3. Replies: 0
    Last Post: 04-04-2008, 09:36 AM
  4. Generate XML request from web form
    By sabatier in forum XML
    Replies: 1
    Last Post: 08-09-2007, 07:53 PM
  5. how to upload a file along with html form data
    By pranith in forum Java Servlet
    Replies: 3
    Last Post: 07-30-2007, 02:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •