* recipients and session and then send the message.
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
MessageRecipients recipients = null;
MessageRecipients ccRecipients = null;
MessageRecipients bccRecipients = null;
// Get the recipients from the servlet request
try {
recipients = getRecipients(request, RECIPIENTS);
ccRecipients = getRecipients(request, CCRECIPIENTS);
bccRecipients = getRecipients(request, BCCRECIPIENTS);
if (recipients == null) {
throw new RecipientException("No recipients could be found");
}
} catch (Exception ae) {
logger.error("Error loading recipient set", ae);
writeError(request, response, ae);
return;
}
// According to the Servlet 2.4 spec:
// "..The default encoding of a request the container uses to create the
// request reader and parse POST data must be ???ISO-8859-1??? if none has
// been specified by the client request. However, in order to
// indicate to the developer in this case the failure of the client
// to send a character encoding, the container returns null
// from the getCharacterEncoding method.."
String requestEncoding = request.getCharacterEncoding();
if (requestEncoding == null) {
requestEncoding = "ISO-8859-1";
}
// Are we sending a URL or an XML message?
String url = request.getParameter("url");
MultiChannelMessage message = null;
// Do we have an explicit charset encoding? Null values are allowed and
// should result in device default charset being used. N.B. the "null"
// string is sent by the form element when the user does not want to
// specify a character encoding
String characterSet = request.getParameter("charset");
if (characterSet.equalsIgnoreCase("null")) {
characterSet = null;
}
// do we need to generate and save the message to file
boolean genMessage = false;
if (request.getParameter("genMsg") != null &&
request.getParameter("genMsg").equalsIgnoreCase("on")) {
genMessage = true;
}
// get the subject
String subject = request.getParameter("subject");
if (characterSet != null) {
subject = ContentUtilities.convertEncoding(
subject,
requestEncoding,
characterSet
);
}
if (!(url.equals(""))) {
message = new MultiChannelMessageImpl(new URL(url), subject, characterSet);
} else {
String xml = request.getParameter("xml");
if (characterSet != null) {
// convert from request char set to specified charset
xml = ContentUtilities.convertEncoding(
xml,
requestEncoding,
characterSet
);
}
message = new MultiChannelMessageImpl(xml, subject, characterSet);
}
try {
message.addAttachments(getAttachments(request));
} catch (Exception ee) {
// log the fact that this failed and carry on.
// Probably not the best thing to do...
logger.error("Failed to attach attachments", ee);
}
// Now set up the from recipient and send the messages to each
// recipient specified in the list
MessageRecipient fromUser = null;
MessageRecipients failures = null;
// file used to for debugging
File outputFile = null;
try {