0

I am new to JSTL.I want display data from a list in JSP.How to do this.I tried something.I am using eclipse luna.

My Status.jsp file

<%@ page import="javax.servlet.jsp.jstl.core.*"%>
<%@ page import="javax.servlet.jsp.el.*" %> 

<c:foreach items="${statusdisplay}" var="statuslist">

            <div class="row">
                <div class="col-md-6 col-sm-12 col-xs-12">
                    <div class="input-group  col-xs-12">
                            <span class="input-group-addon iga">Screen</span>
                            <input type="text" class="form-control" value= "${statuslist.getScreen()}" readonly>
                    </div><br>

                    <div class="input-group col-xs-12">
                            <span class="input-group-addon iga">Show</span>
                            <input type="text" class="form-control" value="${statuslist.getShow()}" readonly>
                    </div><br>
            </div>
</c:foreach>

My Servlet code

request.setAttribute("statusdisplay", statuslist);

            RequestDispatcher requestdispatcher=request.getRequestDispatcher("/Status.jsp");
            requestdispatcher.forward(request,response);

When i run the program without taglib it not showing error and also no output in jsp. when i add <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> it is show No tag "foreach" defined in tag library imported with prefix "c"

How to display data??

Premkumar
  • 57
  • 1
  • 2
  • 12

1 Answers1

0

You have typo for <c:forEach> tag , its foreach in your code . Also you can simply use variables declared in the model class as ${statuslist.screen} and ${statuslist.show}.

see How to avoid Java code in JSP files?

Community
  • 1
  • 1
Santhosh
  • 8,181
  • 4
  • 29
  • 56