Estou fazendo uma aplicação que tem tela de login e senha no caso 3 html que se chama : Inicial.html, PgCerta.html, PgErrada.html, mais umservlet que “chama” estes html. Mas o meu servlet não tá funcionando tenho que usar o RequestDispatcher só que ele não faz a conexão. E ainda dó o erro no ; da última linha. Poderiam me ajudar???
code:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”>
<title>Michelle de Souza </title>
</head>
<body>
<form method=“POST” action=“<a href="http://localhost:8080/TrabalhoWeb/EnviaServlet">http://localhost:8080/TrabalhoWeb/EnviaServlet</a>”>
Login: <INPUT TYPE=text NAME=“nome” size=30 maxlength=“100”>
Senha: <INPUT TYPE=senha NAME=“senha” size=20 maxlength=“100”></form>
<INPUT TYPE=SUBMIT VALUE=“Envia mensagem”>
</body>
</html>
PGCERTA
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”>
<title>title>Trabalho do Mauro Monteiro -Unicarioca</title>
</head>
<body>
Parabéns, você tem acesso liberado!!!
</body>
</html>
PGERRADA
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”>
<title>title>Trabaho do Mauro Monteiro -Unicarioca</title>
</head>
<body>
Você não tem acesso !!!
</body>
</html>
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
/**
- Servlet implementation class for Servlet: EnviaServlet
<em>/
public class EnviaServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
/</em> (non-Java-doc)
-
@see javax.servlet.http.HttpServlet#HttpServlet()
*/
public EnviaServlet() {
super();
}
/* (non-Java-doc)
-
@see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/* (non-Java-doc)
-
@see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String PgCerta = new String( “PgCerta.html” );
String PgErrada = new String( “PgErrada.html” );
RequestDispatcher requestDispatcher = null;
String nome = request.getParameter(“nome”);
String senha = request.getParameter(“senha”);
if( nome.equalsIgnoreCase( “Michelle” ) ){
if(senha.equalsIgnoreCase(“2109”)){
requestDispatcher = request.getRequestDispatcher( PgCerta );
}
else {
requestDispatcher = request.getRequestDispatcher( PgErrada );
}
}
if(nome.equalsIgnoreCase(“mauro”)){
if(senha.equalsIgnoreCase(“1234”)){
requestDispatcher = request.getRequestDispatcher( PgCerta );
}
else{
requestDispatcher = request.getRequestDispatcher( PgErrada );
}
}
requestDispatcher.forward( request, response );