Servlet y JSP
Publicado por Rosa (8 intervenciones) el 14/02/2020 08:22:55
Tengo el siguiente JSP
Cuando lo ejecuto y le doy a ingresar, ya sea introduciendo correctamente o incorrectamente me da un error 500 y no me redirecciona al servlet. ¿Alguien podria ayudarme? gracias
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
51
52
53
54
55
56
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
//Al hacer click en el botón ingresar
if (request.getParameter("btn_ingresar") != null)
{
//Crea dos strings, una para el user y otra para el password.
String username = request.getParameter("txt_username");
String password = request.getParameter("txt_password");
//Si ambas son "admin"...
if (username.equals("admin")&&password.equals("admin"))
{
//Redirecciona al servlet 'crear_departamento.do'
response.sendRedirect("ListadoProductos_almacenesServlet");
}
//Si no...
else
{
//Muestra un mensaje javascript señalando que hay daros erróneos
out.println("<script>alert('Usuario o contraseña incorrecta');</script>");
}
}
%>
<center>
<div style="font-family: sans-serif">
<h2> Banco notNull </h2>
<h3 style="font-family:sans-serif">Ingreso administrador</h3>
<form action="index.jsp" method="POST">
<table border="1" style="font-family:sans-serif">
<tbody>
<tr>
<td>Usuario</td>
<td><input type="text" name="txt_username" value="" /></td>
</tr>
<tr>
<td>Contraseña</td>
<td><input type="password" name="txt_password" value="" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Ingresar" name="btn_ingresar" /></td>
</tr>
</tbody>
</table>
</form>
<hr>
</center>
</body>
</html>
Cuando lo ejecuto y le doy a ingresar, ya sea introduciendo correctamente o incorrectamente me da un error 500 y no me redirecciona al servlet. ¿Alguien podria ayudarme? gracias
Valora esta pregunta


0