Proplema com 2 Acoes no Struts

0 respostas
vjfenix

Ola Pessoal,

Estou estudando o struts e peguei alguns exemplos na net, porem estou tendo problema com a exclusao do Banco, se alguem puder me ajudar..

Meu Form

public class RemoveContatoForm extends org.apache.struts.action.ActionForm {
    /*RemoveContatoForm*/
  private Contato contato;

    public Contato getContato() {
        return contato;
    }

    public void setContato(Contato contato) {
        this.contato = contato;
    }
}

Meu Action

public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
       RemoveContatoForm formulario = ((RemoveContatoForm)form);
        Contato contato = formulario.getContato();
        
        ContatoDAO dao = new ContatoDAO();
        dao.deleta(contato);
        
        return mapping.findForward("remove");
        
    }
}

Strut.config.xml

<form-beans>
        <form-bean name="ContatoForm" type="br.com.caelum.form.ContatoForm"/>
        <form-bean name="RemoveContatoForm" type="com.caelum.form.RemoveContatoForm"/>
    </form-beans>

  <action path="/removeContato" name="RemoveContatoForm"  type="br.com.caelum.action.RemoveContatoAction" >
            <forward name="remove" path="/listaContatos.do"/>
        </action>
lista.jsp
<html>
    <!for
    >
    <c:forEach var="contato" items="${contatos}">
        ${contato.id} - ${contato.nome} - ${contato.endereco}<br/>
        (<a href="removeContato.do?contato.id=${contato.id}">remover</a>)<br/>
    </c:forEach>
</html>

Erro:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.NullPointerException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

Criado 17 de agosto de 2008
Respostas 0
Participantes 1