tags:

views:

44

answers:

3

Hi, what is the best practice or best way of passing form parameters from page to page in a flow? If I have a flow where a user enters data in a form and hits next and repeats this process until they get to an approval page, what ways could I approach this problem to make the retention of data as simple as possible over the flow?

I guess you could put all the information as you go in the session but could you get into memory issues if a lot of people are using your app and going through the flow at the same time?

+3  A: 

You can store data into Cookies or store them into Session and access them between different web pages.

Rachel
+2  A: 

HttpSession is your best bet if you want to track a "wizard" style data entry. Just seconding @Rachel's openion.

The server side component that handles your page submits ( such as Servlets) would have some code like:

public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException    
{
    HttpSession session = req.getSession();
    session.setAttribute("Variable1", request.getParameter("input1"));
    //and so on..

HttpSession Provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user.

ring bearer
Indeed. Http is stateless so sessions are the way to go. As for memory issues, this depends on the server and the way the JVM is configured.
James P.
`HttpSession#putValue()` is **deprecated** since Servlet 2.2 (>10 years ago). Use `HttpSession#setAttribute()` instead. Also, you can just use `request.getSession()` without the boolean to get it regardless of whether it's already created or not.
BalusC
Yep @BalusC +1 .. long long time ago was it when I coded a raw servlet
ring bearer
Since you didn't, I was so kind to edit the answer accordingly.
BalusC
A: 

You may also put attributes in the request scope. They are accessed the same way from EL in your JSPs, but do not require a session. Depending on your situation, you may not wish to start sessions for every user.

Brian M. Carr