Pq qndo salvo ele me da o erro 404

6 respostas
TASF
<%@ 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">

<%
String login=(String) request.getAttribute("login");

%>



<html>

<head>
<script type="text/javascript">
function ValidarDados (){

	i=document.getElementById ('sexo').selectedIndex;
var teste = true;
var saida = "O(s) Seguinte(s) Campo(s) é (são) obrigatório(s):";
if (document.getElementById ('nome').value == ''){
	saida += "\nNome";
	teste = false;	

	if (teste){
alert (" voce vai cadastrar a seguinte pessoa:");
return true;
}else{
alert (saida);
return false;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pagina Principal</title>
</head>
<body>
<%="Seja Bem Vindo "+login %>

<form action="/Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" >
<table border="1">
<tr>
<td>
nome*:
</td>

<td>
<input type="text" id="nome" name="nome">
</td>
</tr>

<tr>
<td>
endereco*:
</td>

<td>
<input type="text" id="endereco" name="endereco">
</td>
</tr>

<tr>
<td>
sexo*:
</td>

<td>
<select id="sexo" name="sexo">
<option>_____Selecione:-{0</option>
<option value="masculino">Masculino</option>
<option value="feminino"> Feminino</option>
 </select>
</td>
</tr>

<tr>
<td>
observações*:
</td>

<td>
<textarea cols="50" rows="20">
 
</textarea>
</td>
</tr>

<tr>
<td>
<input type="submit" id="salvar" name="salvar" value="Salvar" onclick="return ValidarDados ();"> 
</td>

</table>


</form>
</body>
</html>

desde ja grato

6 Respostas

Dani_Gomes

Provavelmente o problema está no:

&lt;form action="/Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" &gt;

Existe o arquivo de CadastroServlet dentro de Cadastro?
Se sim, post o código dele.

leonardobhbr

Primeiramente existe esse servlet no web.xml?

outra coisa tire a primeira barra do action do seu form

<form action="/Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" > 
<form action="Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" >

voce coloca no action o nome do server que esta no web.xml e não o caminho

TASF

Primeiramente existe esse servlet no web.xml?
nao , esta nao como faço para inserir?

leonardobhbr

O link abaixo deve te ajudar
http://javafree.uol.com.br/artigo/9127/Tutorial-basico-de-Servlet.html

CharlesAlves

Ajeita essa formatação

<%@ 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">

<%
	String login = (String) request.getAttribute("login");
%>
<html>

<head>
	<script type="text/javascript">
				function ValidarDados (){
				
						i=document.getElementById ('sexo').selectedIndex;
					var teste = true;
					var saida = "O(s) Seguinte(s) Campo(s) é (são) obrigatório(s):";
					if (document.getElementById ('nome').value == ''){
						saida += "\nNome";
						teste = false;	
					
						if (teste){
					alert (" voce vai cadastrar a seguinte pessoa:");
					return true;
					}else{
					alert (saida);
					return false;
					}
				}
			</script>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Pagina Principal</title>
</head>
<body>
	<%="Seja Bem Vindo " + login%>
	<form action="/Cadastro/CadastroServlet" method="get" id=" fcadastro"
		name="fcadastro">
		<table border="1">
			<tr>
				<td>nome*:</td>
				<td><input type="text" id="nome" name="nome"></td>
			</tr>
			<tr>
				<td>endereco*:</td>
				<td>
					<input type="text" id="endereco" name="endereco">
				</td>
			</tr>
			<tr>
				<td>sexo*:</td>
				<td><select id="sexo" name="sexo">
						<option>_____Selecione:-{0</option>
						<option value="masculino">Masculino</option>
						<option value="feminino">Feminino</option>
				</select></td>
			</tr>

			<tr>
				<td>observações*:</td>
				<td><textarea cols="50" rows="20"></textarea></td>
			</tr>
			<tr>
				<td>
					<input type="submit" id="salvar" name="salvar"
					value="Salvar" onclick="return ValidarDados ();">
				</td>
		</table>
	</form>
</body>
</html>
Mstanguine

leonardobhbr:
Primeiramente existe esse servlet no web.xml?

outra coisa tire a primeira barra do action do seu form

&lt;form action="/Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" &gt; 
&lt;form action="Cadastro/CadastroServlet" method="get" id=" fcadastro" name="fcadastro" &gt;

voce coloca no action o nome do server que esta no web.xml e não o caminho

Ola!
Dependo de como estiver a estrutura de pasta no projeto dele, é necessário sim manter a “/”.
Digo isso, pq ja passei por esse problema: veja

Criado 13 de outubro de 2011
Ultima resposta 14 de out. de 2011
Respostas 6
Participantes 5