title: How to pass an array from servlet to jsp page?
body: <p>I have achieved sending an integer variable to a jsp page using the following code:</p>
  
  <pre><code>resp.sendRedirect(("result.jsp?fibNum=" + fibNum));
  </code></pre>
  
  <p>But when I try the same to pass the array, <code>int[] fibSequence</code> I get the following passed to the address bar of the jsp page:</p>
  
  <p><img src="https://i.stack.imgur.com/qmTGO.png" alt="fibSequence"></p>
  
  <p>Does anyone have any advice on how I can output the array value passed over to the jsp page?`</p>
  
  <p>This is how I sent the array across to the result jsp page within the doPost():</p>
  
  <pre><code>protected void doPost(HttpServletRequest req, HttpServletResponse resp)
              throws ServletException, IOException {
          // TODO Auto-generated method stub
  
  
          // read form fields
          String fibNum = req.getParameter("fibNum");
  
  
          try{
                //Get reference from server's registry
                Registry registry = LocateRegistry.getRegistry("127.0.0.1");
  
                //Lookup server object from server's registry
                IFibonacci fibonacci_proxy = (IFibonacci)registry.lookup("PowerObject");
  
  
                int fibMax = Integer.parseInt(fibNum);
  
               //Invoke server object's methods 
               //Get Fibonacci array.
               int[] fibSequence = fibonacci_proxy.fibonacciArrayTest(fibMax);
  
  
               for (int value : fibSequence) {
                  System.out.println(value);
               }
  
  
              //System.out.println(Arrays.toString(fibSequence));
  
  
              }catch(NotBoundException nbe){
                nbe.printStackTrace();
              }catch(RemoteException re){
                re.printStackTrace();
              }
  
              //send input to the result page using a redirect
              //resp.sendRedirect(("result.jsp?fibNum=" + fibNum));
              resp.sendRedirect(("result.jsp?fibSequence=" + fibSequence));
  
            }
  </code></pre>
  
  <p>How I've tried to retrieve the array values on the jsp page and print them, but I'm getting a <code>fibSequence cannot be resolved to a variable</code> although this is the name of the array passed over:</p>
  
  <pre><code>&lt;a href="home.jsp"&gt;Return to Main&lt;/a&gt;&lt;br&gt;
               &lt;%String[] var_array=request.getParameterValues("fibSequence");%&gt;
               &lt;%System.out.print(""+fibSequence);%&gt;
          &lt;/form&gt;     
  </code></pre>