Problemas com Servlet

2 respostas
awilaz

Boa tarde a todos,

Estou com uma aplicação onde envio dados através de requisição POST para um servlet. Acontece que quando dou um submit ele não encontra o Servlet.
Abaixo seguem meus arquivos Web.xml e o JSP

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
	<display-name>midiaControler</display-name>
	<welcome-file-list>
		<welcome-file>/pages/index.html</welcome-file>
	</welcome-file-list>
	<servlet>
		<description></description>
		<display-name>GeneroBean</display-name>
		<servlet-name>GeneroBean</servlet-name>
		<servlet-class>br.com.midia.bean.GeneroBean</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>GeneroBean</servlet-name>
		<url-pattern>/GeneroBean</url-pattern>
	</servlet-mapping>
</web-app>

E aqui meu 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>
<script type="text/javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>.: Cadastro Gênero Musical :.</title>
</head>
<body>
<form id="genero" method="post" action="/GeneroBean">
		<table>
			<tr>
				<td>Nome :</td>
				<td><input type="text" size="30" maxlenght="30" name="nome" /></td>
			</tr>	
			<tr>
				<td>Status :</td>
				<td><input type="checkbox" name="status" /></td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" value="Salvar" name="salvar" id="salvar"/></td>
			</tr>
		</table>
	</form>
</body>
</html>

Abaixo a mensagem de erro

[b][color=darkblue]type Status report

message /GeneroBean

description The requested resource (/GeneroBean) is not available.[/color][/b]

2 Respostas

ramilani12

Acho que faltou adicionar o contexto no seu form:

<form id="genero" method="post" action="contexto/GeneroBean">
awilaz

Era isso mesmo… vlw.

Brigadão

Criado 9 de maio de 2008
Ultima resposta 13 de mai. de 2008
Respostas 2
Participantes 2