EJB programming & troubleshooting: Data insert of several webpages at time in database

  1. Data insert of several webpages at time in database (2 messages)

    Hay I have a doubt about a scenario,If any one could help me to solve this I will be thankful to them

    I have web trasaction(a collectin of forms/pages).In that user have to enter data in several webpages.The data he enter should push into database at server.Here my question is how can push the data in a single instance or single hit.

    Can we get the bundale of data at single instance after he submits in the last page of entire trasaction( I guess for every chage of page the data will send to server)

    If there is scope of collecting the data at server how to aviod the data duplication (this may occurs once user comeback to the previous pages of submitte and submit data).

    Please help me in regards of this
    Regards, Harikrishna
  2. The scope I think you want to use is the user's session (HttpSession).

    Typically in this situation, as the user moves to the next page (or next step in the collection process) you would save the data they just entered into the user's session. You may want to create a custom object (value object) that you keep in the session and add data to it as they move from page to page. This is to keep you from having to keep track of a bunch of parameters independently. You could just send the value object that contains all the data to your data layer once they submit the last page.

    If the user moves back and forth thru the pages before submitting, its ok since youll just be replacing the data in memory and not sending it to the db until the final page has been submitted.
  3. I recently completed an app that gathers data for a survey over four pages. Because my data was specific on each page I created four JavaBeans and did my error checking in the jsp, then populated the bean and placed the bean in the session, the user could go back and change any page, on the final page I provide an aggregation of all the data, then the user can print and then save the data.

    When the data is saved there is a method in a manager bean such as:

      void saveData(Object1 obj1, Object2 obj2, Object3 obj3)
          throws DuplicateDataException;

    Each Object.. instance was retrieved from the session and passed to this function where in the manager bean I do all of the JDBC work.

    You can get the object from the session:

    Object obj = (Object)session.getAttribute("myObject");

    Hope this helps,
    David King