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);
}
}
}
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);
}
}
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());
}
}
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);
}
}
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());
}
}
Aggregations