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