use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.
the class StylesTag method serializeElements.
/**
* Write out the HTML tags for each element.
*
* @param styles The styles.
* @throws IOException If there was an error writing the styles.
*/
private void serializeElements(final Collection styles) throws IOException {
final JspWriter out = this.pageContext.getOut();
final Iterator elements = styles.iterator();
while (elements.hasNext()) {
final Element element = (Element) elements.next();
element.serialize(out);
}
}
use of javax.servlet.jsp.JspWriter in project com.revolsys.open by revolsys.
the class ScriptsTag method doStartTag.
/**
* Process the start tag.
*
* @return SKIP_BODY
* @throws JspException If there was an exception processing the tag.
*/
@Override
public int doStartTag() throws JspException {
try {
final WebUiContext context = WebUiContext.get();
if (context != null) {
final Page page = context.getPage();
if (page != null) {
final JspWriter out = this.pageContext.getOut();
String contextPath = context.getContextPath();
if (contextPath.equals("/")) {
contextPath = "";
}
final Iterator scripts = page.getScripts().iterator();
while (scripts.hasNext()) {
final String script = (String) scripts.next();
out.print("<script type=\"text/javascript\" src=\"");
out.print(contextPath);
out.print(script);
out.println("\">\n</script>");
}
}
}
final SiteNodeController controller = (SiteNodeController) this.pageContext.findAttribute("rsWebController");
if (controller instanceof PageController) {
final PageController page = (PageController) controller;
writeScripts(page.getScripts());
}
} catch (final Throwable t) {
log.error(t.getMessage(), t);
}
return SKIP_BODY;
}
use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.
the class PrintExceptionTag method doTag.
@Override
public void doTag() {
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = pageContext.getOut();
if (exception != null) {
try {
out.println("<div class=\"stackTrace\">");
exception.printStackTrace(new PrintWriter(out));
out.println("</div>");
} catch (IOException e) {
log.error("Can't write output to HTML page", e);
}
}
}
use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.
the class SendEmailTag method doEndTag.
@Override
public int doEndTag() throws JspException {
JspWriter out = pageContext.getOut();
Email email = new Email(includeSentTime);
String statusMessage;
if (recipients.isEmpty())
statusMessage = _t("Error: Please add at least one recipient.");
else
try {
// set addresses
InternetAddress ia = new InternetAddress(senderAddress);
email.setFrom(ia);
// We must continue to set "Sender:" even with only one mailbox
// in "From:", which is against RFC 2822 but required for older
// Bote versions to see a sender (and validate the signature).
email.setSender(ia);
email.setSubject(subject, "UTF-8");
for (Recipient recipient : recipients) email.addRecipient(recipient.type, recipient.address);
// TODO: Comment out until we determine if this is necessary
// email.fixAddresses();
// set the text and add attachments
email.setContent(message, attachments);
// send the email
I2PBote.getInstance().sendEmail(email);
// delete attachment temp files
for (Attachment attachment : attachments) {
if (!attachment.clean())
log.error("Can't clean up attachment: <" + attachment + ">");
}
statusMessage = _t("The email has been queued for sending.");
} catch (PasswordException e) {
throw new JspException(e);
} catch (NoIdentityForSenderException e) {
statusMessage = _t("Error sending email: {0}", _t("No identity matches the sender/from field: {0}", e.getSender()));
log.error("Error sending email", e);
} catch (AddressException e) {
statusMessage = _t("Error sending email: {0}", _t("Address doesn't contain an Email Destination or an external address: {0}", e.getRef()));
log.error("Error sending email", e);
} catch (Exception e) {
statusMessage = _t("Error sending email: {0}", e.getLocalizedMessage());
log.error("Error sending email", e);
}
try {
out.println(statusMessage);
} catch (IOException e) {
log.error("Can't write output to HTML page", e);
}
return EVAL_PAGE;
}
use of javax.servlet.jsp.JspWriter in project i2p.i2p-bote by i2p.
the class FormatPlainTextTag method doTag.
@Override
public void doTag() {
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = pageContext.getOut();
try {
// Handle both CRLF and LF
text = text.replaceAll(CRLF + CRLF, "<p/>");
text = text.replaceAll(CRLF, "<br/>");
text = text.replaceAll(LF + LF, "<p/>");
text = text.replaceAll(LF, "<br/>");
// Insert a br tag between two p tags. Do it twice to handle >2 p tags in a row.
text = text.replaceAll("<p/><p/>", "<p/><br/><p/>");
text = text.replaceAll("<p/><p/>", "<p/><br/><p/>");
out.println(text);
} catch (IOException e) {
log.error("Can't write output to HTML page", e);
}
}
Aggregations