JSP (Java Server Page) - Problema de sesion con JSPs y Servlet

 
Vista:

Problema de sesion con JSPs y Servlet

Publicado por Firematta (1 intervención) el 15/04/2009 09:57:08
El problema basicamente es que estoy batallando para poder utilizar variables de sesion en un sistema que cuenta con varias paginas tipo JSP, donde estoy manejando la informacion con un servlet.
De la primera pagina(donde esta la forma) a la segunda si obtengo la informacion, es decir, me despliega los datos correctamente, pero esa misma informacion la trato de mandar a la tercer y me truena el programa

Me marca lo siguiente

org.apache.jasper.JasperException: No se puede compilar la clase para JSP:

Ha tenido lugar un error en la línea: 14 en el archivo jsp: /NextPage.jsp
Syntax error on token "/", delete this token
11:
12: <table border="0" cellpadding="0" width="1000px" >
13:
14: <tr><td><b>City:</b></td> <td><%= DatosReservacion.get<b>cars</b>() %></td></tr>
15: <tr> <td><b>Aerolinea: </b></td> <td><%= DatosReservacion.getairline() %></td></tr>
16: <tr><td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getarrivalDate() %></td>
17: <td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getdepartureDate() %></td></tr>

Ha tenido lugar un error en la línea: 14 en el archivo jsp: /NextPage.jsp
Syntax error on token "(", Expression expected after this token
11:
12: <table border="0" cellpadding="0" width="1000px" >
13:
14: <tr><td><b>City:</b></td> <td><%= DatosReservacion.get<b>cars</b>() %></td></tr>
15: <tr> <td><b>Aerolinea: </b></td> <td><%= DatosReservacion.getairline() %></td></tr>
16: <tr><td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getarrivalDate() %></td>
17: <td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getdepartureDate() %></td></tr>

Las paginas son las siguientes:

->Cars.jsp

<%@ page session="true" %>
<html>
<head>
<title>Renta a Car!</title>
<style type="text/css">
body {background-color: #ee82ee}
</style>
<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>

<script language="JavaScript">
var cal13 = new CalendarPopup();
</script>
</head>

<body>
<h1>Renta a Car!</h1>

<form method="post" name="form1" action="servlet/HandlerServlet">
City:
<select name="city">
<option value="ACAPULCO">ACAPULCO, GRO. </option>
<option value="AGUASCALIENTES">AGUASCALIENTES </option>
<option value="CABO SAN LUCAS">CABO SAN LUCAS </option>
<option value="CANCUN">CANCUN </option>
</select>

<br /> <br /> <br />

Departure Date:
<input type="text" size="25" value="" name="date13"/>
<input value=">>" type="button" id="anchor13" name="anchor13" title="cal13.select(document.forms[0].date13,'anchor13','dd/MM/yyyy');" onclick="cal13.select(document.forms[0].date13,'anchor13','dd/MM/yyyy');">

<br /> <br /> <br />

Arrival Date:
<input type="text" size="25" value="" name="date14"/>
<input value=">>" type="button" id="anchor14" name="anchor14" title="cal13.select(document.forms[0].date14,'anchor14','dd/MM/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null);" onclick="cal13.select(document.forms[0].date14,'anchor14','dd/MM/yyyy',(document.forms[0].date14.value=='')?document.forms[0].date13.value:null);" >

<br /> <br /> <br />

Airline:
<select name="airline">
<option value="AERO CALIFORNIA">AERO CALIFORNIA</option>
<option value="AEROCARIBE">AEROCARIBE</option>
<option value="AEROLINEAS ARGENTINAS">AEROLINEAS ARGENTINAS</option>
<option value="AEROLINEAS AZTECA">AEROLINEAS AZTECA</option>
<option value="AEROLINEAS INTERNACIONALES">AEROLINEAS INTERNACIONALES</option>
<option value="AEROLINEAS NICARAGUENSES">AEROLINEAS NICARAGUENSES</option>
<option value="AEROLITORAL">AEROLITORAL</option>
<option value="AEROMAR">AEROMAR</option>
<option value="AEROMEXICO">AEROMEXICO</option>
<option value="AEROPERU">AEROPERU</option>
<option value="AIR CANADA">AIR CANADA</option>
<option value="AIR FRANCE">AIR FRANCE</option>
</select>

<br /> <br /> <br />

<input type="hidden" name="action" value="SET">
<input type="submit" value="Submit Info" >

</form>


</body>
</html>

->Detalles.jsp

<%@ page language = "java" session="true" import="java.util.*, Ejemplo.Reservation" %>
<%
Reservation DatosReservacion = (Reservation)session.getValue("Ejemplos.DatosRes");
if (DatosReservacion != null ) {
%>
<html>
<head>
<title>Rent Details</title>
<style type="text/css">
body {background-color: #ee82ee}
</style>
</head>

<body>
<h1>Pagina 2</h1>

<table border="0" cellpadding="0" width="1000px" >

<tr><td><b>City:</b></td> <td><%= DatosReservacion.getcity() %></td></tr>
<tr> <td><b>Aerolinea: </b></td> <td><%= DatosReservacion.getairline() %></td></tr>
<tr><td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getarrivalDate() %></td>
<td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getdepartureDate() %></td></tr>


</table>
<br>
<br>
<br>
<form method="post" name="form2" action="">
<input type="hidden" name="action" value="DISPLAY">
<input type="submit" value="Submit Info" >
</form>
</body>

</html>
<% }
else
{ %>
<html>
<body>
<h1>ERROR!!</h1>
</body>
</html>
<%}%>

-> NextPage.jsp

<%@ page language = "java" session="true" import="java.util.*, Ejemplo.Reservation" %>
<%
Reservation DatosReservacion = (Reservation)session.getValue("Ejemplos.DatosRes");
if (DatosReservacion != null ) {
%>
<html>
<head>
<title>Next Page</title>
</head>
<body>

<table border="0" cellpadding="0" width="1000px" >

<tr><td><b>City:</b></td> <td><%= DatosReservacion.get<b>cars</b>() %></td></tr>
<tr> <td><b>Aerolinea: </b></td> <td><%= DatosReservacion.getairline() %></td></tr>
<tr><td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getarrivalDate() %></td>
<td><b>Arrival Date: </b></td> <td><%= DatosReservacion.getdepartureDate() %></td></tr>

</table>
</body>
</html>
<%}%>

El servlet /HandlerServlet

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import Ejemplo.Reservation;

public class HandlerServlet extends HttpServlet
{

public void doGet(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException
{
HttpSession session = req.getSession(true);
if (session == null)
{
rsp.sendRedirect("error.html");
}

Reservation DatosReservacion = new Reservation();
rsp.setContentType("text/html");


String action = req.getParameter("action");
if (action.equals("SET"))
{

DatosReservacion.setcity(req.getParameter("city"));
DatosReservacion.setairline(req.getParameter("airline"));
DatosReservacion.setarrivalDate(req.getParameter("date13"));
DatosReservacion.setdepartureDate(req.getParameter("date14"));


session.setAttribute("Ejemplos.DatosRes", DatosReservacion);
String url="/Detalles.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, rsp);
}

if (action.equals("DISPLAY"))
{
session.setAttribute("Ejemplos.DatosRes", DatosReservacion);
String url="/NextPage.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, rsp);
}
}

public void doPost(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException
{
doGet(req,rsp);
}

}

La clase Reservacion del paquete Ejemplo es:

import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import Ejemplo.Reservation;

public class HandlerServlet extends HttpServlet
{

public void doGet(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException
{
HttpSession session = req.getSession(true);
if (session == null)
{
rsp.sendRedirect("error.html");
}

Reservation DatosReservacion = new Reservation();
rsp.setContentType("text/html");


String action = req.getParameter("action");
if (action.equals("SET"))
{

DatosReservacion.setcity(req.getParameter("city"));
DatosReservacion.setairline(req.getParameter("airline"));
DatosReservacion.setarrivalDate(req.getParameter("date13"));
DatosReservacion.setdepartureDate(req.getParameter("date14"));


session.setAttribute("Ejemplos.DatosRes", DatosReservacion);
String url="/Detalles.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, rsp);
}

if (action.equals("DISPLAY"))
{
session.setAttribute("Ejemplos.DatosRes", DatosReservacion);
String url="/NextPage.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, rsp);
}
}

public void doPost(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException
{
doGet(req,rsp);
}

}

Por favor, si pueden ver el error avisenme.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder