Ciao a tutti,
mi sono appena iscritto e vorrei avere una vostra consulenza circa una web application che sto realizzando.
Si tratta di inserire nome e cognome nel DB utilizzando una maschera JSP per l'inserimento e tramite una classe Action e una Form i dati dovrebbero inserirsi nel DB.
L' errore che ottengo a vale dell'inserimento dei dati è il seguente :
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:357)
org.apache.struts.chain.commands.CreateActionForm.execute(CreateActionForm.java:92)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
Eclipse inoltre mi dà errore su una classe InsertUserAction :
package utente;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.sql.DataSource;
public class InsertUserAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
if (isCancelled(request))
return mapping.findForward("welcome");
else {
DataSource dataSource = null;
dataSource = getDataSource(request, "prova");
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
InsertUserForm userForm = (InsertUserForm) form;
try{
ResultSet rs = null;
PreparedStatement statement2 = conn.prepareStatement("insert into prova (nome, cognome)values (?,?)");
statement2.setString(1,userForm.getNome());
statement2.setString(2,userForm.getCognome());
statement2.executeUpdate();
conn.commit();
}catch (Exception e){
e.printStackTrace();
conn.rollback();
conn.close();
}
return mapping.findForward("success");
}
}
}
Dove ho sbagliato?
Vi ringrazio per la disponibilità