ciao ragazzi, sono nuovo del forum. vi scrivo per un problema con la mia piccola applicazione web tomcat/mysql..
praticamente è un gestionale per il gioco del fantacalcio. c'è una serie di servlet che generano risposte utilizzate dallo strato di view, implementato in adobe flex.
il mio problema sorge durante l'invio delle formazioni. una volta ogni 100, viene inviata la risposta di formazione salvata correttamente ma sul db non c'è traccia del salvataggio.. e neppure nel log c'è traccia di errori.
ho pensato ad una risposta vecchia cachata a causa di quella nuova che arriva troppo tardi.. questo perché la macchina su cui faccio girare l'applicazione è DECISAMENTE vecchiotta (pentium III con 128mb di ram
)
comunque vi posto la parte di codice interessata, magari potete darmi una mano a gestire meglio l'errore visto che così fa un po' pena (è 1 app che ho creato 2 anni fa x esercitarmi con java/hibernate/mysql)
codice:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
status = OK;
Session hibernateSession = HibernateUtil.currentSession();
hibernateSession.beginTransaction();
Principal p = request.getUserPrincipal();
if (p != null) {
// ... serie di controlli sulla formazione inviata...
} else {
status = ERROR;
errorMessage = "Non sei abilitato ad eseguire questa operazione";
}
try {
Document doc = XmlResponseFactory.getInstance().newXml();
buildXml(doc, request, hibernateSession, rf);
String xmlString = XmlResponseFactory.getInstance().xmlToString(doc);
response.setContentType("text/xml;charset=ISO-8859-1");
response.getOutputStream().println(xmlString);
response.getOutputStream().flush();
response.getOutputStream().close();
} catch(Exception e) {
e.printStackTrace();
}
hibernateSession.getTransaction().commit();
}
private void buildXml(Document doc, HttpServletRequest request, Session hibernateSession, RegistroFormazioni rf) {
Element root = doc.createElement("response");
doc.appendChild(root);
Element st = doc.createElement("status");
if (status == OK) {
st.setAttribute("Status", Integer.toString(OK));
st.setAttribute("Message", "Formazione modificata correttamente");
rf.setSuccesso(true);
} else if (status == ERROR) {
st.setAttribute("Status", Integer.toString(ERROR));
st.setAttribute("Message", errorMessage);
rf.setSuccesso(false);
rf.setErrore(errorMessage);
}
root.appendChild(st);
}
grazie anticipatamente a chiunque risponderà!