开发者

Java Web App: Passing form parameters across multiple pages

what is the best practice or best way of passin开发者_如何学Cg 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?


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜