Erro HTTP 404 no jsp

4 respostas
jsnpereira

Olá, pessoal!

Estou revisando a estudar na java há um mês parado por causa começo na faculdade e tinha perdido na minha cabeça.. Favor me ajudar qual resolução essa problemas.

Mensagem de Erro:
HTTP Status 404 - /TesteServletComJSP/Cadastro.jsp

--------------------------------------------------------------------------------

type Status report

message /TesteServletComJSP/Cadastro.jsp

description The requested resource (/TesteServletComJSP/Cadastro.jsp) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.30
Cadastro.jsp
<%@ 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">
<title>Insert title here</title>
</head>
<body>

<form action="IncluirServlet" method="get">
<table>
<tr><td>Nome:</td><td><input type="text" name="nome"></td></tr>
<tr><td>Idade:</td><td><input type="text" name="idade"></td></tr>
</table>
</form>
</body>
</html>
Servlet
*/
public class IncluirServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String nome = request.getParameter("nome");
		int idade = Integer.parseInt(request.getParameter("idade"));
		
		Cadastro c = new Cadastro();
		
		ArrayList<Cadastro> list = new ArrayList<Cadastro>();
				
		c.setNome(nome);
		c.setIdade(idade);
		
		request.setAttribute("lista",c);
		
		RequestDispatcher rd = request.getRequestDispatcher("TelaLista");
		rd.forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
Lista
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<% Cadastro cad = (Cadastro) request.getAttribute("lista"); %>
<body>
Nome: <%cad.getNome(); %> <br>
Idade: <%cad.getIdade(); %>
</body>
</html>

Espero que vocês me ajudem..

Obrigado!

4 Respostas

ederfreitas

Definiu seu Servlet no web.xml?

jsnpereira

Acho que não… qual passo de configuração a definir o servlet no web.xml?

Aguardo ao retorno. Obrigado!

ederfreitas

Aqui tem um tutorial bem bacana que acredito que ajude você a solucionar o seu problema.

http://javafree.uol.com.br/artigo/9127/Tutorial-basico-de-Servlet.html

jsnpereira

ederfreitas:
Aqui tem um tutorial bem bacana que acredito que ajude você a solucionar o seu problema.

http://javafree.uol.com.br/artigo/9127/Tutorial-basico-de-Servlet.html

Já descobri a configuração que já fiz antes… mas Tomcast demorou para abrir…

Valeu me mandar o link e vou guardar por lembrete para configurações…

Então e testei para executar e enviar os dados para outra tela… mas as informações ficou vazia… veja os códigos em cima… é mesmo…

Aguardo ao retorno… obrigado!

Criado 11 de abril de 2011
Ultima resposta 11 de abr. de 2011
Respostas 4
Participantes 2