Take the 2-minute tour ×

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);

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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"));
share|improve this answer
Thanks for the response! I'll try it out I've never heard of storing something in the session –  Robogeeko Jul 18 '12 at 17:17
You're welcome. To learn more about sessions, you may find this answer helpful: stackoverflow.com/questions/3106452/… –  BalusC Jul 18 '12 at 17:30
Thanks a lot! Works well! –  Robogeeko Jul 18 '12 at 17:30
You're welcome. Be careful that you don't store too much data in the session. Use where possible session.removeAttribute() to remove it when you're ready with it. –  BalusC Jul 18 '12 at 17:34

Your Answer


