CARGAR DATOS AL MOMENTO DE REALIZAR LA BUSQUEDA
Publicado por Anthony (1 intervención) el 27/10/2019 19:22:48
Deseo que al momento de presionar en el boton buscar ,al momento de dirigirme a mi pagina Actualiza.jsp, se carguen los datos alusivos a la busqueda que estoy realizando:
MI FRM donde buscare una pelicula por titulo:
MI SERVLET DE BUSQUEDA
MI FRM DE ACTUALIZAR
MI SERVLET ACTUALIZAR
GRACIAS
MI FRM donde buscare una pelicula por titulo:
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
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link href="css/estilos.css" rel="stylesheet">
<title>Busqueda de Pelicula</title>
</head>
<body>
<div id="loguin">
<h2 id="title">Busqueda de Pelicula por Titulo</h2>
<form action="listapel" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">Ingrese Titulo</label>
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Igresa Titulo" name="txtDesc" >
</div>
<button type="submit" class="btn btn-primary">Consultar</button>
</form>
</div>
</body>
</html>
MI SERVLET DE BUSQUEDA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("Ingresamos al servlet Listapel");
String descr = request.getParameter("txtDesc");
String url;
System.out.println(descr);
//Pelicula p = new Pelicula();
//p.setDes_pel(descr);
GestionPelicula gp = new GestionPelicula();
Pelicula pe = gp.buscarPelicula(descr);
if(pe!=null) {
url="/actualiza.jsp";
System.out.println("Pelicula Localizada"+pe);
}else {
url="/consulta.jsp";
System.out.println("No se encontro Descripcion"+pe);
}
//request.setAttribute("Codigo", descr);
request.getRequestDispatcher(url).forward(request, response);
MI FRM DE ACTUALIZAR
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
<div id="loguin">
<h2 id="title">Actualizacion de Pelicula</h2>
<form action="updatepel" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">Codigo</label>
<input type="number" class="form-control" id="exampleInputEmail1" name="txtCod" ">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Titulo</label>
<input type="text" class="form-control" id="exampleInputPassword1" name="txtTitulo">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Descripcion</label>
<input type="text" class="form-control" id="exampleInputPassword1" name="txtDesc">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Cantidad</label>
<input type="text" class="form-control" id="exampleInputPassword1" name ="txtCantidad" >
</div>
<div class="form-group">
<label for="exampleInputPassword1">Precio</label>
<input type="text" class="form-control" id="exampleInputPassword1" name="txtPrecio" >
</div>
<div class="form-group">
<label for="exampleInputPassword1">Fecha</label>
<input type="date" class="form-control" id="exampleInputPassword1" name="txtFecha">
</div>
<button type="submit" class="btn btn-primary" id="btnupdate">Actualizar Pelicula</button>
</form>
</div>
MI SERVLET ACTUALIZAR
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("Ingresamos al servlet Actualizar");
/*Declaramos variables*/
int codigo;
String titulo;
String descripcion;
int cantidad;
double precio;
String fecha ;
String url;
/*Capturamos entradas*/
codigo=Integer.parseInt(request.getParameter("txtCod"));
titulo=request.getParameter("txtTitulo");
descripcion=request.getParameter("txtDesc");
cantidad=Integer.parseInt(request.getParameter("txtCantidad"));
precio=Double.parseDouble(request.getParameter("txtPrecio"));
fecha=request.getParameter("txtFecha");
/*Guardamos el UP en un objeto p de tipo Pelicula*/
Pelicula p = new Pelicula();
p.setCod_pel(codigo);
p.setTit_pel(titulo);
p.setDes_pel(descripcion);
p.setCant_etn(cantidad);
p.setPre_pel(precio);
p.setFhc_estreno(fecha);
/*ejecutamos el toString*/
System.out.println("Los datos que vamos a updatear son:"+p);
/*LLamo al metodo Update*/
GestionPelicula gp = new GestionPelicula();
int ok = gp.ActualizaPelicula(p);
if(ok==0) {
System.out.println("Error de Actualizacion");
url="/actualiza.jsp";
}else {
System.out.println("Actualizacion Exitosa");
url="/consulta.jsp";
}
request.getRequestDispatcher(url).forward(request, response);
}
Valora esta pregunta


0