I want to retrieve the ArrayList from a JSP page to servlet when submitting the form on the JSP page. I am trying following code:
Code of Pass.jsp is:
<form action="GetListServlet">
<%
    ArrayList al=new ArrayList();
    al.add("Naman");
    al.add("Gupta");
    request.setAttribute("allnames", al); 
%>
<input type="submit" value="Show List"></form>
doGet() method of GetListServlet is :-
protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException 
{
    ArrayList al=(ArrayList)request.getAttribute("allnames");
    System.out.print(al.get(0));
} 
But I am getting NullPointerException at System.out.print(al.get(0)).
Can anyone tell me how can I get arraylist of jsp page on the servlet page ?