This is my jsp page.
Code of jsp page :-
<img src='image.jpg' height=200px width=200px>
<form action="buyserv">
<%
ArrayList al=new ArrayList();
al.add("naman");
al.add("gupta");
request.setAttribute("allproducts", al);
RequestDispatcher rd = request.getRequestDispatcher("/buyserv");
rd.forward(request, response);
%>
<input type="submit" value="Buy"></form>
<a href="ShowAllProducts.jsp"><input type="button" value="Continue"></a>
I want that on clicking Buy button,the arraylist (al) should be passed to buyserv(servlet). However the list is getting passed to buyserv but the problem is that the jsp page is not getting displayed.But I want to display the jsp page as well as pass the arraylist on button click. Can anyone tell me how can I do so ?
Code of buyserv :-
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
ArrayList al=(ArrayList)request.getAttribute("allproducts");
PrintWriter out=response.getWriter();
out.print(al.get(0));
}