Bom, eu estou iniciando com servlets e estou tentando fazer um exemplo contendo uma caixa com nome e senha, ai vc digita e se estiver correto exibe uma mensagem, só que, estou tendo problemas quando executo o arquivo aparece no browser, tudo direitinho, as caixas, os labels, e o botão logar, só que quando clico no logar abre uma nova aba no browser a aparece um negócio escrito 404 error e nao sei como resolver, estou colocando os 3 arquivos que fiz no netbeans 5.5:
Esse é o index.jsp
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Fazendo um teste com login e senha</title>
</head>
<body>
<form action="NovoServlet" method="processRequest">
Login: <input type="text" name="login" />
Senha :<input type="text" name="senha" />
<input type="submit" value="Logar" />
</form>
</body>
</html>
Esse é o NovoServlet.jsp
import java.io.IOException;
import java.io.PrintWriter;
import java.net.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.*;
public class NovoServlet extends HttpServlet {
public void destroy(){
super.destroy();
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=ISO-8859-1");
String usuario = request.getParameter("usuario");
String senha = request.getParameter("senha");
String html =
"<html><head>"+
"<title>Fazendo um teste com campos</title>"+
"</head>"+
"<body>";
if (usuario.equalsIgnoreCase("a") && senha.equalsIgnoreCase("a"))
html = "Ok, bem vindo Moa.";
else
html = "usuario nao autorizado";
html += "</body></html>";
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.print(html);
writer.close();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void init() throws ServletException {
super.init();
}
public String getServletInfo() {
return "Short description";
}
}
E esse é o web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>NovoServlet</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>NovoServlet</servlet-name>
<url-pattern>/NovoServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>