user571099
user571099

Reputation: 1511

retrieve servlet variable via jstl

i have an arraylist of strings in my servlet which im passing forwarding using this:

//in servlet

ArrayList<String> output = new ArrayList<String>();
//populate arraylist with values here

//forward the string
request.setAttribute("myData ", output);
request.getRequestDispatcher("Home.jsp").forward(request, response);

i know that i can access this in scriplet notation:

ArrayList<String> myData = (ArrayList<String>)request.getAttribute("myData");

how do i access this in jstl?

Upvotes: 0

Views: 2165

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94645

You may use <c:forEach /> to iterate the list - JSTL reference doc.

<c:forEach var="name" items="${myData}">
   <br/>${name}
</c:forEach>

Upvotes: 1

Related Questions