0

I want to use Arraylist by JSTL at the JSP page through the JavaBean. Meaning there is some ArrayLists in the JavaBean. And i handle the JavaBean at the Servlet. In this course i have a problem at the jsp line 10,11. I want to know how can i fix this.

//GreenView.jsp
1<body>
2<TABLE border=1>
3   <TR>
4       <TD width=150>Want to see Sarr array</TD>
5      <TD width=150>want to see Rarr array</TD>
6       
7   </TR>
8   <c:forEach var="C" begin="0" end="${GreenTable.cnt}">
9   <TR>
10      <TD>${GreenTable.Sarr[C]}</TD>
11      <TD>${GreenTable.Rarr[C]}</TD>
12  </TR>
13  </c:forEach>
14
15</TABLE>

JavaBean is like this

public class GreenList {


private Integer cnt;
public Integer getCnt() {
    return cnt;
}
public void setCnt(Integer cnt) {
    this.cnt = cnt;
}
private ArrayList<String> Sarr = new ArrayList<String>();
private ArrayList<String> Rarr = new ArrayList<String>();


public ArrayList<String> getSarr() {
    return Sarr;
}
public void setSarr(String sarr) {
    Sarr.add(sarr);
}
public ArrayList<String> getRarr() {
    return Rarr;
}
public void setSarr(String rarr) {
    Rarr.add(rarr);
}

Servlet is like this

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession session4 = request.getSession();
    String ID = (String) session4.getAttribute("uID");
    GreenList list = readDB(ID);
    request.setAttribute("GreenTable", list);
    RequestDispatcher dispatcher =request.getRequestDispatcher("GreenView.jsp");
    dispatcher.forward(request, response);
    }
Wow
  • 1
  • 1
  • 1
    `i have a problem at the line 25` , where is line 25 – Ramanlfc Jun 18 '16 at 04:12
  • sry i edited. i mean 10,11 line. – Wow Jun 18 '16 at 04:33
  • Next time when you get an exception you couldn't understand, you should feed it to a search engine, or at least include it unmodified in the question. Namely, it represents the whole answer at its own, it's just a matter of being able to translate it in layman's terms. – BalusC Jun 18 '16 at 06:23

0 Answers0