syntax error on tokens: misplaced construct(s)
大家好,我在用ECLIPSE写时JSP遇到上述问题,下面是我的代码,请大家帮忙。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import = "javax.naming.*" %>
<%
FlightBean[] flights = null;
if(request.getParameter("depLoc") != null) {
String depLoc = request.getParameter("depLoc");
try {
InitialContext ctx = new InitialContext();
TicketReservationRemote searchDepLoc = (TicketReservationRemote)ctx.lookup("TicketReservation/TicketReservationImpl");
flights = searchDepLoc.searchDepLoc(depLoc);
}
catch (NamingException e) {
e.printStackTrace();
}
}
%>
<html>
<head>
<title>Travel Agent</title>
</head>
<body>
从<html>到<body>系统报错“syntax error on tokens: misplaced construct(s)”
<% if(flights != null) { %>
<h2>Search Results</h2>
<table align = "center">
<tr>
<th>Flight ID</th>
<th>Airplane ID</th>
<th>Seat Number</th>
<th>Departure Location</th>
<th>Departure Date</th>
<th>Destination</th>
<th>Cost</th>
</tr>
<% for(int i = 0; i < flights.length; i++) {
FlightBean flight = flights[i];
out.pirntln("<tr><td>" + flight.getFlightID() + "</td><td>" +
flight.getAirplaneID() + "</td><td>" + flight.getSeatNo() +
"</td><td>" + flight.getDepLoc() + "</td><td>" + flight.getDepDate() +
"</td><td>" + flight.getDes() + "</td><td>" + flight.getCost() + "</td></tr>");
}
%>
</table>
<%
}
%>
<h2>Search by Departure Location</h2>
<form action = "SearchDepLoc.jsp" method = "post">
<table align = "center">
<tr>
<td align = "right">Departure Location</td>
<td align = "left">
<input type = "text" name = "depLoc">
</td>
</tr>
<tr>
<td align = "right">
<input type = "submit" value = "submit">
</td>
<td align = "left">
<input type = "reset" value = "reset">
</td>
</tr>
</table>
</form>
<a href = "TravelAgent.html">Return to Menu</a>
</body>
</html>