facebook

Saving the session (or html) on the server

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #264388 Reply

    pmohanan
    Member

    For one of our application , the user spends more than 6minutes on the form & we would like to save the html (saving should be transparent to the user) so that in case of PC/Server crash we could retrieve the info from the server.

    Is it possible using JSF (an event that fires every 2min) to save the HTML on the server say like <session_id>.html.

    Regards

    #264414 Reply

    rogue_dev
    Member

    You need to do something on the client machine. Once the HTML has finished loading on the client machine, the connection is severed.

    Use Javascript and a Javascript timer, then gather up the form information and send it using the Javascript XMLHttpRequest object to send the information to the server. Be sure to save the information as a “draft” rather than live data.

    I have left out all sorts of plumbing, but a search for XMLHttpRequest should fill it in.

    Now you can say that you are using AJAX 🙂

    #264432 Reply

    pmohanan
    Member

    Hi…,

    Thanks a lot for the wonderful info….
    I just had another question (and might be a stupid question). I do I gather the form information at one shot instead of going through all the fields one by one. I would be happy if I can get the HTML source (including the changes done by the user) & then pass it back to to the server to save it in a file on the file system.

    Regards.

    #264657 Reply

    rogue_dev
    Member

    Well, you can do this a couple of ways:
    – go through the form DOM and gather up the current values. This is a generic way to do this, and should work for every form.
    – generate form specific Javascript at the server which directly accesses the values (document.myform.myfield.value)

    You are not really passing back the HTML source (and you really do not want to). You just get the values and pass them back as field=value pairs (/mysite/servlet/savedraft?id=userid&field1=value1&field2=value2&….)

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Saving the session (or html) on the server

You must be logged in to post in the forum log in