Search in sources :

Example 31 with PageContext

use of javax.servlet.jsp.PageContext in project i2p.i2p-bote by i2p.

the class ShowAttachmentsTag method doTag.

@Override
public void doTag() throws IOException, JspException {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();
    try {
        // make an HTML link for each attachment
        List<Part> parts = email.getParts();
        for (int partIndex = 0; partIndex < parts.size(); partIndex++) {
            Part part = parts.get(partIndex);
            if (Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition())) {
                String filename = Functions.escapeXml(part.getFileName());
                out.println("<a href=\"showAttachment?messageID=" + email.getMessageID() + "&folder=" + folder + "&part=" + partIndex + "\">" + filename + "</a> (" + JSPHelper.getHumanReadableSize(part) + ") <br/>");
            }
        }
    } catch (MessagingException e) {
        throw new JspException("Can't parse email.", e);
    }
}
Also used : JspException(javax.servlet.jsp.JspException) MessagingException(javax.mail.MessagingException) Part(javax.mail.Part) PageContext(javax.servlet.jsp.PageContext) JspWriter(javax.servlet.jsp.JspWriter)

Example 32 with PageContext

use of javax.servlet.jsp.PageContext in project jodd by oblac.

the class VtorViolationMessageTag method doTag.

@Override
public void doTag() throws IOException {
    PageContext pageContext = ((PageContext) getJspContext());
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String output = VtorUtil.resolveValidationMessage(request, violation);
    pageContext.getOut().write(output);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PageContext(javax.servlet.jsp.PageContext)

Example 33 with PageContext

use of javax.servlet.jsp.PageContext in project jodd by oblac.

the class TextTag method doTag.

@Override
public void doTag() {
    PageContext pageContext = (PageContext) getJspContext();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    key = key.trim();
    String message;
    if (StringUtil.isEmpty(key)) {
        return;
    }
    message = defaultOnly ? findDefaultMessage(request, key) : findMessage(request, key);
    if (message == null) {
        message = UNKNOWN_PREFIX + key + UNKNOWN_SUFFIX;
    } else {
        for (String[] param : params) {
            String paramName = param[0];
            String paramValue = param[1];
            String value = paramValue;
            if (paramName.startsWith(KEY_ATTR_NAME)) {
                value = defaultOnly ? findDefaultMessage(request, paramValue) : findMessage(request, paramValue);
                if (value == null) {
                    value = UNKNOWN_PREFIX + paramValue + UNKNOWN_SUFFIX;
                }
            }
            message = StringUtil.replace(message, '{' + paramName + '}', value);
        }
    }
    JspWriter out = pageContext.getOut();
    try {
        out.print(HtmlEncoder.text(message));
    } catch (IOException ioex) {
    // ignore
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 34 with PageContext

use of javax.servlet.jsp.PageContext in project jodd by oblac.

the class VtorViolationsJsonMessagesTag method doTag.

@Override
public void doTag() throws IOException {
    PageContext pageContext = ((PageContext) getJspContext());
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String output = VtorUtil.createViolationsJsonString(request, violations);
    pageContext.getOut().write(output);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PageContext(javax.servlet.jsp.PageContext)

Example 35 with PageContext

use of javax.servlet.jsp.PageContext in project jodd by oblac.

the class IteratorTag method doTag.

@Override
public void doTag() throws JspException {
    if (items == null) {
        return;
    }
    JspFragment body = getJspBody();
    if (body == null) {
        return;
    }
    PageContext pageContext = (PageContext) getJspContext();
    // create an iterator status if the status attribute was set.
    if (status != null) {
        iteratorStatus = new IteratorStatus(this.modulus);
        TagUtil.setScopeAttribute(status, iteratorStatus, scope, pageContext);
    }
    if (items instanceof Collection) {
        iterateCollection((Collection) items, from, count, pageContext);
    } else if (items.getClass().isArray()) {
        iterateArray((Object[]) items, from, count, pageContext);
    } else if (items instanceof String) {
        iterateArray(Converter.get().toStringArray(items), from, count, pageContext);
    } else {
        throw new JspException("Provided items are not iterable");
    }
    // cleanup
    if (status != null) {
        TagUtil.removeScopeAttribute(status, scope, pageContext);
    }
    TagUtil.removeScopeAttribute(var, scope, pageContext);
}
Also used : JspFragment(javax.servlet.jsp.tagext.JspFragment) JspException(javax.servlet.jsp.JspException) Collection(java.util.Collection) PageContext(javax.servlet.jsp.PageContext)

Aggregations

PageContext (javax.servlet.jsp.PageContext)36 JspContext (javax.servlet.jsp.JspContext)12 JspWriter (javax.servlet.jsp.JspWriter)10 IOException (java.io.IOException)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 ArrayList (java.util.ArrayList)5 JspException (javax.servlet.jsp.JspException)5 FeatureDescriptor (java.beans.FeatureDescriptor)3 Test (org.junit.Test)2 BannedPeer (i2p.bote.network.BannedPeer)1 DhtPeerStats (i2p.bote.network.DhtPeerStats)1 DhtPeerStatsRow (i2p.bote.network.DhtPeerStatsRow)1 RelayPeer (i2p.bote.network.RelayPeer)1 PrintWriter (java.io.PrintWriter)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1