Erro no ServLet .....description The requested resource (/prova/pagina/controller) is not available

2 respostas
P

Olá , galera estou fazendo um trabalho de faculdade onde só posso

usar Servlet sem taglib mas estou tendo um erro ao chamar uma opção do menu.jsp

me dá essa mensagem

HTTP Status 404 - /prova/pagina/controller

type Status report
message /prova/pagina/controller
description The requested resource (/prova/pagina/controller) is not available.

JBossWeb/2.0.0.GA

o fluxo das telas é o seguinte primeiro chama o index.jsp do contexto depois

chama o menu.jsp que está no diretório pagina e quando escolho uma opção

que vai chamar o servlet dá o erro …

alguém pode me ajudar …

abs

--index.jsp
<!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>Menu Principal</title>
<h1>Menu Principal</h1>
</head>
<body>
<table width="75%" height="50" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td colspan="2">Escolha uma Opção </td>
  </tr>
  <tr></tr>
  <tr></tr>  
  <tr> 
    <td>
      <a >Lista de Clientes</a>
    &lt;/td&gt;
  &lt;/tr&gt;
  
&lt;/table&gt;

&lt;/body&gt;
&lt;/html&gt;

--menu.jsp

&lt;h1&gt;Menu Principal&lt;/h1&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table width="75%" height="50" border="0" cellpadding="0" cellspacing="0"&gt;
  &lt;tr&gt; 
    &lt;td colspan="2"&gt;Escolha uma Opção &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;/tr&gt;  
  &lt;tr&gt; 
    &lt;td&gt;
      <a >Lista de Clientes</a>
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;  
    &lt;td&gt;
      <a >Incluir de Cliente</a>
    &lt;/td&gt;
  &lt;/tr&gt;
 
&lt;/table&gt;

&lt;/body&gt;
&lt;/html&gt;

---web.xml

&lt;welcome-file-list&gt;
		&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
		&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
		&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
		&lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
		&lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
		&lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
	&lt;/welcome-file-list&gt;
	
	&lt;servlet&gt;
	   &lt;servlet-name&gt;action&lt;/servlet-name&gt;
	   &lt;servlet-class&gt;br.com.paulo.prova.servlet.ServletAction&lt;/servlet-class&gt;
	&lt;/servlet&gt;
	
	&lt;servlet-mapping&gt;
       &lt;servlet-name&gt;action&lt;/servlet-name&gt;
	   &lt;url-pattern&gt;/controller&lt;/url-pattern&gt;
	&lt;/servlet-mapping&gt;
&lt;/web-app&gt;

----
---servlet
public class ServletAction extends HttpServlet {
	RequestDispatcher  rd=null;
	public ServletAction() {
		// TODO Auto-generated constructor stub
	}
	public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       try {
            PrintWriter out = resp.getWriter();
            String acao=req.getParameter("acao");
            Class clazz = Class.forName("br.com.paulo.prova.action." + acao + "Action");
            System.out.println("acao="+acao);
            System.out.println("idcliente="+req.getParameter("idcliente"));
            Action action = (Action) clazz.newInstance();
            String Mapping = action.execute(req,resp);
            
            rd = req.getRequestDispatcher(Mapping);

            rd.forward(req,resp);


            out.println("&lt;h1&gt;Lista&lt;/h1&gt;"+acao);
       }catch(Exception e){
    	   req.setAttribute("erro", e);
    	   rd = req.getRequestDispatcher("/pagina/erro.jsp");
    	   rd.forward(req,resp);
    	   System.out.println("Erro="+e);
       }
	}

2 Respostas

P

achei o erro..

ao chamar o servlet atraves do jsp tinha que passar assim.....

[code]

# <td>
# Lista de Clientes
# </td>
# </tr>
# <tr>
# <td>
# Incluir de Cliente
# </td>
# </tr>

[/code}

P
a heref="/prova/controller?acao=LIsta"
<a
>
Criado 26 de junho de 2008
Ultima resposta 26 de jun. de 2008
Respostas 2
Participantes 1