How to iterate the session in JSP page?

后端 未结 2 1160
悲哀的现实
悲哀的现实 2021-01-27 18:50

How to iterate the session and keep the every submit value in same page till the session end?




    <         


        
2条回答
  •  情书的邮戳
    2021-01-27 19:01

    There is no need for iterator.
    In your action set the values to session attributes.
    In Jsp retrieve them using there name e.g.:

    Name:
    Age:
    Marks:
    Country:

    This should do.

    Update 1:

    For displaying all the set of values entered :
    1) Create a POJO to store all these values (call Person).
    2) In your action maintain a arraylist of Person objects.
    3) At every submit create a new person object and add it to person list.
    4) In jsp iterate over the person list and display all the values.
    NO Need for session. Avoid using session as much as possible.

提交回复
热议问题