Reputation: 95
here is my problem i need to pass an arrayList from servlet to the JSP
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
String text = request.getParameter("text");
ServletContext context = getServletContext();
context.log(text);
StringProcess(text,context);
response.sendRedirect("sucess.jsp");
}
Upvotes: 0
Views: 2150
Reputation: 1035
You can put that array list to either the sesion or request by calling setAttribute() method, like this:
request.setAttribute("arrName", arrObj);
Or
session.setAttribute("arrName", arrObj);
In your jsp page scriptlet, you can simply call request.getAttribute("arrName")
or session.getAttribute("arrName")
to get that array. Mind the type casting also.
If you use the core JSTL, you can loop through the array like this:
<c:forEach items="${arrName}" var="tmp">
...
</c:forEach>
Upvotes: 1