Servlet não executa! + tomcat 5.0.28

13 respostas
W

Olá pessoal, ajudem-me por favor!!

Estou tentando executar um servlet simples e não consigo.

O Tomcat inicia normal, mas quando tento executar, clicando no botão do formulario, aparece:
HTTP Status 404 - /servlets-examples/HTTPGetServlet


type Status report

message /servlets-examples/HTTPGetServlet

description The requested resource (/servlets-examples/HTTPGetServlet) is not available.


Apache Tomcat/5.0.28

Podem me ajudar?

Obrigado!!!

Wellington

13 Respostas

J

Oi

wcandeia, vamos la… poste aí o conteudo do seu web.xml e a URL que estas usando para acessar o Servlet, e como tem um form, poste tb a action dele…

A, se der, poste a servlet tb… hehehe

T+

W

Olá jeveaux, obrigado desde já!

O form:

<FORM
		ACTION="http://localhost:8080/servlet/HTTPGetServlet"
		METHOD="GET">
		<P>Click the button to have the servlet send
			an HTML document</P>
		<INPUT TYPE="submit" VALUE="Get HTML Document">
	</FORM>
W
O servlet:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class HTTPGetServlet extends HttpServlet {
 public void doGet( HttpServletRequest request,
 					HttpServletResponse response )
 	throws ServletException, IOException
 {
 	PrintWriter output;
 
 	response.setContentType( "text/html" ); // tipo de conteúdo
 	output = response.getWriter(); // obtém o escritor

 	// cria e envia página HTML para o cliente
 	StringBuffer buf = new StringBuffer();
	buf.append( "<HTML><HEAD><TITLE>\n" );
	buf.append( "A Simple Servlet Example\n" );
	buf.append( "</TITLE></HEAD><BODY>\n" );
	buf.append( "<H1>Welcome to Servlets!</H1>\n" );
	buf.append( "</BODY></HTML>" );
	output.println( buf.toString() );
	output.close(); // fecha o fluxo PrintWriter
 }
}
G

opa… wcandeia, tenta chamar somente HTTPGetServlet no action do form… :wink:

W

Coloquei três msg’s pq não tava dando certo! Não tá dando certo colocar o web.xml. Quando puder
veja para mim, aparentemente tá certo. O tomcat reconhece e tudo
na inicialização. Será que é pq eu não adicionei no Context, em server.xml?

Valeu!

Wellington

G

como está o teu xml??? :wink:

W

Quando tento enviar aqui no forum da um erro no phpnuke!

“The html tags you attempted to use are not allowed”

Wellington

G

humm… me manda como MP

W

Não dá…também aparece a mesma mensagem!

Wellington

G

ahh cara tá dificil… heheh

manda por e-mail -> [email removido]

conseguiu algum progresso ???

W

Olá JavaPlayer, obrigado pela ajuda!

Consegui resolver o problema, era o arquivo web.xml que estava “mal escrito”. De qualquer forma, obrigado!

Wellington

G

ok… wellington! qualquer coisa estou por aí! :wink:

W

Valeu mesmo! Tá blz então.

Wellington

Criado 30 de novembro de 2004
Ultima resposta 2 de dez. de 2004
Respostas 13
Participantes 3