Servlets - convertir servlet a jsp

 
Vista:

convertir servlet a jsp

Publicado por katherine (4 intervenciones) el 06/04/2013 21:02:37
tengo este servlet quisiera saber como puedo convertir en jsp :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
try {
 
            HttpSession car = request.getSession(true);
            if (request.getParameter("x")!=null){
                int op = Integer.parseInt(request.getParameter("x"));
                List<Carrito> alu = (List<Carrito>)car.getAttribute("pedido");
                alu.remove(op);
            }
            List<Carrito> venta = (List<Carrito>)car.getAttribute("pedido");
 
            out.println("<head><style type='text/css'>.fondo{color:white;background-color:black}</style></head>");
 
 
 
	    out.println("<table width=650 align=center border=1 cellspacing=0>");
	    out.println("<tr class='fondo'><th>Codigo<th>Producto<th>Precio<th>Unidades<th>Total<th>&nbsp;");
            int i=0;
            for (Carrito item:venta){
                out.println("<tr><td align=center>" + item.getCodigo()+
		                "<td>" + item.getProducto() +
				"<td align=center>" + item.getPrecio() +
				"<td align=center>" + item.getUnidades() +
                                "<td align=center>" + item.getPrecio()*item.getUnidades() +
                                "<td align=center><a href=sCart?x=" + i + ">Quitar</a>");
            }
            out.println("<tr><td colspan=6>Total de items : " + venta.size());
            out.println("</table>");
        } catch(Exception ex) {
            out.println(ex);
        }
    }
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
Imágen de perfil de Jhonnathan Emilio Cardona Saineda

convertir servlet a jsp

Publicado por Jhonnathan Emilio Cardona Saineda (6 intervenciones) el 08/04/2013 21:54:19
Tienes algunos problemas con el HTML. Necesita un <body> y necesitas cerrar cada </td>. Te dejo algo que puede servirte. Saludos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<head><style type='text/css'>.fondo{color:white;background-color:black}</style>
</head>
<body>
<%
try {
 
            HttpSession car = request.getSession(true);
            if (request.getParameter("x")!=null){
                int op = Integer.parseInt(request.getParameter("x"));
                List<Carrito> alu = (List<Carrito>)car.getAttribute("pedido");
                alu.remove(op);
            }
            List<Carrito> venta = (List<Carrito>)car.getAttribute("pedido");%>
 
            <table width=650 align=center border=1 cellspacing=0>
	       <tr class='fondo'><th>Codigo<th>Producto<th>Precio<th>Unidades<th>Total<th>&nbsp;
        <%    int i=0;
            for (Carrito item:venta){
			%>
             <tr><td align=center><%=item.getCodigo()%> </td><td><%=item.getProducto()%></td>
			 <td align=center><%=item.getPrecio()%> </td> <td align=center><%=item.getUnidades()%></td>
			 <td align=center><%=(item.getPrecio()*item.getUnidades())%>
           <% }%>
            <tr><td colspan=6>Total de items :  <%=venta.size()%>
            </table>
			<%
        } catch(Exception ex) {
            out.println(ex);
        }
    }
	%>
 
  </body></html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar