Reputation: 53
I am making a web page that displays large sets of data. Initially, the user enters a form in a jsp that includes them uploading a file, and checking boxes for options. When the user hits submit, it goes to a servlet that processes the form information. The information is processed and as a result, several large arrays of Strings are created. I then redirect to the display page, passing the parameters as follows:
request.setAttribute("blah", array);
request.getRequestDispatcher(page).forward(request,response);
On the display page I want to be able to give the user the option to choose which page he/she wants to view. To do this, I made links on the top of the page that passed the page number as a parameter:
<a href="DisplayPage?Page=x">Page x</a>
(DisplayPage is the servlet displaying the data, so the link points to itself with a different parameter)
The problem is, in order to display the data again, the large arrays must be passed back to DisplayPage. How can I achieve this?
Upvotes: 0
Views: 794
Reputation: 1108742
Either pass them as multi-value request parameter in the link as well,
<a href="DisplayPage?Page=x&blah=value1&blah=value2&blah=value3">Page x</a>
String[] blah = request.getParameterValues("blah");
or store it in the session, if necessary identified by an unique ID which you also pass as request parameter.
String id = UUID.randomUUID().toString();
request.getSession().setAttribute(id, array);
request.setAttribute("id", id);
<a href="DisplayPage?Page=x&blah=${id}">Page x</a>
Object blah = request.getSession().getAttribute(request.getParameter("blah"));
Upvotes: 1