Search in sources :

Example 11 with PageContext

use of javax.servlet.jsp.PageContext 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);
        }
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) PrintWriter(java.io.PrintWriter)

Example 12 with PageContext

use of javax.servlet.jsp.PageContext 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);
    }
}
Also used : PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 13 with PageContext

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

the class UrlTag method doTag.

@Override
public void doTag() {
    final PageContext pageContext = (PageContext) getJspContext();
    final URLCoder.Builder builder = URLCoder.build(baseUrl);
    for (int i = 0; i < attrs.size(); i += 2) {
        builder.queryParam(attrs.get(i), attrs.get(i + 1));
    }
    if (var == null) {
        final JspWriter out = pageContext.getOut();
        try {
            out.print(builder.get());
        } catch (final IOException ioex) {
        // ignore
        }
    } else {
        pageContext.setAttribute(var, builder.get());
    }
}
Also used : URLCoder(jodd.net.URLCoder) PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 14 with PageContext

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

the class UnsetTag method doTag.

@Override
public void doTag() throws JspException {
    PageContext pageContext = (PageContext) getJspContext();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String scopeValue = scope != null ? scope.toLowerCase() : SCOPE_PAGE;
    if (scopeValue.equals(SCOPE_APPLICATION)) {
        request.getServletContext().removeAttribute(name);
    } else if (scopeValue.equals(SCOPE_SESSION)) {
        request.getSession().removeAttribute(name);
    } else if (scopeValue.equals(SCOPE_REQUEST)) {
        request.removeAttribute(name);
    } else if (scopeValue.equals(SCOPE_PAGE)) {
        pageContext.removeAttribute(name);
    } else {
        throw new JspException("Invalid scope: " + scope);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) PageContext(javax.servlet.jsp.PageContext)

Example 15 with PageContext

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

the class AuthTag method doTag.

@Override
public void doTag() throws JspException {
    final PageContext pageContext = ((PageContext) getJspContext());
    final HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    final UserSession userSession = UserSession.get(request);
    final boolean invokeBody = (userSession != null) == auth;
    if (invokeBody) {
        TagUtil.invokeBody(getJspBody());
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) 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