Fixed try/catch statement in ContactMailController

This commit is contained in:
rjy7 2010-05-19 21:31:17 +00:00
parent eea97d50e9
commit a005d26f1c

View file

@ -76,7 +76,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
body.put("errorMessage", body.put("errorMessage",
"This application has not yet been configured to send mail. " + "This application has not yet been configured to send mail. " +
"An smtp host has not been specified in the configuration properties file."); "An smtp host has not been specified in the configuration properties file.");
bodyTemplate = "commentForm/error.ftl"; bodyTemplate = "commentForm/error.ftl";
} }
else { else {
@ -87,6 +87,7 @@ public class ContactMailController extends FreeMarkerHttpServlet {
String validationMessage = validateInput(webusername, webuseremail, String validationMessage = validateInput(webusername, webuseremail,
comments); comments);
if (validationMessage != null) { if (validationMessage != null) {
// rjy7 We should reload the form, not go to the error page! // rjy7 We should reload the form, not go to the error page!
body.put("errorMessage", body.put("errorMessage",
@ -168,16 +169,15 @@ public class ContactMailController extends FreeMarkerHttpServlet {
String msgText = composeEmail(webusername, webuseremail, comments, String msgText = composeEmail(webusername, webuseremail, comments,
deliveryfrom, originalReferer, vreq.getRemoteAddr()); deliveryfrom, originalReferer, vreq.getRemoteAddr());
// debugging // Write the email to a backup file
FileWriter fw = null;
try { try {
fw = new FileWriter(context.getRealPath(EMAIL_BACKUP_FILE_PATH),true); FileWriter fw = new FileWriter(context.getRealPath(EMAIL_BACKUP_FILE_PATH),true);
PrintWriter outFile = new PrintWriter(fw);
writeBackupCopy(outFile, msgText, spamReason);
} }
catch (IOException e){ catch (IOException e){
LOG.error("Can't open file to write email backup"); LOG.error("Can't open file to write email backup");
} }
PrintWriter outFile = new PrintWriter(fw);
writeBackupCopy(outFile, msgText, spamReason);
// Set the smtp host // Set the smtp host
Properties props = System.getProperties(); Properties props = System.getProperties();