-3

I try to implement the for loop from the Java Standard Tag Library as follows:

<c:forEach begin="0" end="${car.totalNumberOfCars - 1}" >                                   
    <a  class="car-link" href="model.jsp?id=${car.cars[0].carId}" id="${car.cars[0].carId}" >
                <div class="col-sm-6 col-md-3"> 
                    <div class="thumbnail parts"> 
                        <img src="${car.cars[0].carImg}" alt="..." height="300"/>
                        <div class="caption">
                            <h1>${car.cars[0].carName}</h1>
                            <p> ${car.cars[0].carDesc}</p>                                        
                        </div>
                    </div>
            </a>                                    
        </div>   
</c:forEach>                            

However, I get the following error printed on the console:

  error: package org.apache.taglibs.standard.tag.rt.core does not exist
David Enoma
  • 311
  • 1
  • 13

3 Answers3

2

Looks like you are missing the .jar file for JSTL

Try download it from here:

https://mvnrepository.com/artifact/javax.servlet/jstl/1.2

Then add it to your lib folder inside WEB-INF (or the same place you keep your other .jar files like the mysql driver you mentioned in comments)

Jonathan Laliberte
  • 2,672
  • 4
  • 19
  • 44
0

You have some tags switched up. You have this simplified structure:

<c:forEach>
    <a>
        <div>
            <div>
                <img/>
                <div>
                    <h1></h1>
                    <p></p>                                        
                </div>
            </div>
        </a>                                    
    </div>   
</c:forEach>

But the closing a tag and the last closing div tag are in the wrong order, flip them around.

Lino
  • 19,604
  • 6
  • 47
  • 65
  • 3
    And you think that that causes the error `error: package org.apache.taglibs.standard.tag.rt.core does not exist` ? – Erwin Bolwidt Jun 04 '18 at 12:27
  • @ErwinBolwidt I can't ensure that the error will be fixed with this as I am unable to test it. But I have seen in a lot of languages that the compilers complain with generic errors like "Symbol not found" just because you messed the order of tags or the scope of classes and so on up – Lino Jun 04 '18 at 12:31
  • @DavidEnoma So you're not getting the error anymore? – Lino Jun 04 '18 at 12:36
  • No I am no more getting the errors, thanks Lino – David Enoma Dec 03 '19 at 00:42
0

I changed the Javabean construct car, but Jonathan's answer was correct though.

 <% car.setCars();
                for (int i = 0; i < car.getTotalNumberOfCars(); i++) {
                   out.println("<a  class=\"car-link\" href=\"model.jsp?id="+ car.cars[i].getCarId()+"\" id"+ "=\"" +car.cars[0].getCarId() + "\">");
                   out.println("<div class=\"col-sm-6 col-md-3\"> ");
                   out.println("<div class=\"thumbnail parts\">");
                   out.println("<img src=\""+ car.getCars()[i].getCarImg()+ "\" alt=\"...\""+ " height=\"300\">");
                   out.println("<div class=\"caption\"");
                   out.println("<h1>"+car.getCars()[i].getCarName()+"</h1>");
                   out.println("<p>"+car.getCars()[i].getCarDesc()+"</p>");
                   out.println("</div>");
                   out.println("</div>");
                   out.println("</a>");
                   out.println("</div>");

                }
            %>
David Enoma
  • 311
  • 1
  • 13