Pagina jsp não está achando o servlet, por que?

3 respostas
M

Eu estou usando o JBoss-3.2.3 com tomcat 5 como servers. E estou usando Eclipse 2.1 mais Lomboz 213 para desenvolvimento.
Ai eu editei a pagina index.jsp e coloquei meu form lá e com o action apontando para o servlet. mas quando dou o submit o servlet não é achado. segui o codigo abaixo:

[color=“red”]Pagina: index.jsp[/color]

<!-- Copyright © 2002 by ObjectLearn. All Rights Reserved. -->

<html>
<head>
<title>Cadastro de cidades</title>
</head>
<body>

&lt;h1&gt;Cadastro de cidade&lt;/h1&gt;

<form name=“form1” method=“post” [color=“red”]action="/webcity/cadastro"[/color] ><label></label>
<table width=“100%” border=“0” cellspacing=“0” cellpadding=“0”>
<tr>
<td width=“7%”><label>Id</label>&nbsp;</td>
<td width=“93%”><input name=“id” type=“text” id=“id” maxlength=“10”></td>
</tr>
<tr>
<td><label>Nome</label>&nbsp;</td>
<td><input name=“nome” type=“text” id=“nome” maxlength=“40”></td>
</tr>
<tr>
<td><label>Uf</label>&nbsp;</td>
<td><input name=“uf” type=“text” id=“uf” maxlength=“3”></td>
</tr>
<tr>
<td><label>DDD</label>
&nbsp;</td>
<td><input name=“ddd” type=“text” id=“ddd” maxlength=“3”></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><label></label></td>
<td><input type=“submit” name=“Submit” value=“Submit”></td>
</tr>
</table>

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

[color=“blue”]Arquivo web.xml[/color]

<?xml version=“1.0” encoding=“UTF-8”?>

<!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”

“<a href="http://java.sun.com/dtd/web-app_2_3.dtd">http://java.sun.com/dtd/web-app_2_3.dtd</a>”>

<!-- Copyright © 2002 by ObjectLearn. All Rights Reserved. -->

<web-app>

<servlet>

<servlet-name>Cadastro</servlet-name>

<servlet-class>com.city.servlet.Cadastro</servlet-class>

<init-param>

<param-name>operation</param-name>

<param-value>1</param-value>

</init-param>

</servlet>

<servlet-mapping>

<servlet-name>Cadastro</servlet-name>

<url-pattern>/webcity/*</url-pattern>

</servlet-mapping>

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<error-page>

<error-code>404</error-code>

<location>/error.jsp</location>

</error-page>

</web-app>

eu já tentei acessar o servlet de tudo quanto é jeito:
http://localhost:8080/webcity/Cadastro
http://localhost:8080/webcity/cadastro
http://127.0.0.1:8080/webcity/Cadastro
http://localhost:8080/webcity/servlet/Cadastro
http://localhost:8080/webcity/servlets/Cadastro
/webcity/Cadastro

mas o servlet não é encontrado de jeito nenhum. o engraçado e que analisando o conteudo do webcity.war a classe do servlet está lá bonitinha. WEB-INF/classes/com/city/servlet/Cadastro.class

Qual o problema???

3 Respostas

D

Ae max, tenta alterar essa parte

para essa

&lt;servlet-mapping&gt;
        &lt;servlet-name&gt;Cadastro&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/webcity/cadastro&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;

dai vc chama no form

action="webcity/cadastro"

deve funcionar…

M

Valew cara! era isso mesmo!!

D

as ordens, hehehe

Criado 2 de julho de 2004
Ultima resposta 3 de jul. de 2004
Respostas 3
Participantes 2