0
votes

I'll just put this here. I literally have no leads on this

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<title>Employee table</title>
</head>
<body>
<%! import net.multivision.employee.Employee; %>
<%! import java.util.List; %>
<% List<Employee> table = (List<Employee>)session.getAttribute("table"); %>
<table class="table table-striped">
<tr>
<th>id</th>
<th>Name</th>
<th>Age</th>
<th>Dept</th>
<th>Salary</th>
<th>Start Date</th>
<th>Type</th>
</tr>
<% for(Employee e : table){ %>
<tr>
<td><%= e.getId() %></td>
<td><%= e.getName() %></td>
<td><%= e.getAge() %></td>
<td><%= e.getDept() %></td>
<td><%= e.getSalary() %></td>
<td><%= e.getStartdate() %></td>
<td><%= e.getType() %></td>
</tr>
<% } %>
</table>
</body>
</html>

The error is on <% } %> and is preventing me from publishing/compiling. All the error says is http://puu.sh/auyYc/2b40efef1f.png

Even if the error was based on something outside the jsp I don't even know where to look based on this.

2

2 Answers

0
votes

The issue is because you are coding JSP as servlet. in JSP the scope of a <% %> ends within the %>, in your case you create a loop signature in a snippet and are trying to close it in another snippet, which by rule of thumb would not know about the loop at all.

Try using tag library instead

define the tag library as

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

and then update the code for the loops as

<c:forEach items="${table}" var="e">
<tr>
<td><%= e.getId() %></td>
<td><%= e.getName() %></td>
<td><%= e.getAge() %></td>
<td><%= e.getDept() %></td>
<td><%= e.getSalary() %></td>
<td><%= e.getStartdate() %></td>
<td><%= e.getType() %></td>
</tr>
</c:forEach>
0
votes

Try changing your import statements using the following syntax:

<%@ page import="net.multivision.employee.Employee" %>
<%@ page import="java.util.List" %>

Relevant Documentation on Page Directives

A declaration declares a variable or method for use later in the JSP. A directive gives the container instructions in regard to the current page.