use of javax.servlet.jsp.JspTagException in project grails-core by grails.
the class JspInvokeGrailsTagLibTag method doAfterBody.
@Override
public int doAfterBody() throws JspException {
BodyContent b = getBodyContent();
if (invocationCount > 0) {
if (b != null) {
jspWriter = b.getEnclosingWriter();
invocationBodyContent.add(b.getString());
bodyInvokation = true;
b.clearBody();
}
}
invocationCount--;
setCurrentArgument();
if (invocationCount < 1) {
tagContent = sw.toString();
int i = 1;
StringBuilder buf = new StringBuilder();
for (String body : invocationBodyContent) {
String replaceFlag = "<jsp-body-gen" + i + ">";
int j = tagContent.indexOf(replaceFlag);
if (j > -1) {
buf.append(tagContent.substring(0, j)).append(body).append(tagContent.substring(j + replaceFlag.length(), tagContent.length()));
tagContent = buf.toString();
if (tagContent != null) {
try {
jspWriter.write(tagContent);
out.close();
} catch (IOException e) {
throw new JspTagException("I/O error writing tag contents [" + tagContent + "] to response out");
}
}
buf.delete(0, buf.length());
}
}
return SKIP_BODY;
}
return EVAL_BODY_BUFFERED;
}
use of javax.servlet.jsp.JspTagException in project libresonic by Libresonic.
the class FormatBytesTag method doEndTag.
public int doEndTag() throws JspException {
Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
String result = StringUtil.formatBytes(bytes, locale);
try {
pageContext.getOut().print(result);
} catch (IOException x) {
throw new JspTagException(x);
}
return EVAL_PAGE;
}
use of javax.servlet.jsp.JspTagException in project libresonic by Libresonic.
the class UrlTag method formatUrl.
private String formatUrl() throws JspException {
String baseUrl = UrlSupport.resolveUrl(value, null, pageContext);
StringBuffer result = new StringBuffer();
result.append(baseUrl);
if (!parameters.isEmpty()) {
result.append('?');
for (int i = 0; i < parameters.size(); i++) {
Parameter parameter = parameters.get(i);
try {
result.append(parameter.getName());
if (isUtf8Hex() && !isAsciiAlphaNumeric(parameter.getValue())) {
result.append(ParameterDecodingFilter.PARAM_SUFFIX);
}
result.append('=');
if (parameter.getValue() != null) {
result.append(encode(parameter.getValue()));
}
if (i < parameters.size() - 1) {
result.append("&");
}
} catch (UnsupportedEncodingException x) {
throw new JspTagException(x);
}
}
}
return result.toString();
}
use of javax.servlet.jsp.JspTagException in project sling by apache.
the class AbstractDispatcherTagHandler method doEndTag.
/**
* Called after the body has been processed.
*
* @return whether additional evaluations of the body are desired
*/
public int doEndTag() throws JspException {
log.debug("AbstractDispatcherTagHandler.doEndTag");
final SlingHttpServletRequest request = TagUtil.getRequest(pageContext);
// set request dispatcher options according to tag attributes. This
// depends on the implementation, that using a "null" argument
// has no effect
final RequestDispatcherOptions opts = new RequestDispatcherOptions();
opts.setForceResourceType(resourceType);
opts.setReplaceSelectors(replaceSelectors);
opts.setAddSelectors(addSelectors);
opts.setReplaceSuffix(replaceSuffix);
// ensure the path (if set) is absolute and normalized
if (path != null) {
if (!path.startsWith("/")) {
path = request.getResource().getPath() + "/" + path;
}
path = ResourceUtil.normalize(path);
}
// check the resource
if (resource == null) {
if (path == null) {
// neither resource nor path is defined, use current resource
resource = request.getResource();
} else {
// check whether the path (would) resolve, else SyntheticRes.
Resource tmp = request.getResourceResolver().resolve(path);
if (tmp == null && resourceType != null) {
resource = new DispatcherSyntheticResource(request.getResourceResolver(), path, resourceType);
// remove resource type overwrite as synthetic resource
// is correctly typed as requested
opts.remove(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE);
}
}
}
try {
// create a dispatcher for the resource or path
RequestDispatcher dispatcher;
if (resource != null) {
dispatcher = request.getRequestDispatcher(resource, opts);
} else {
dispatcher = request.getRequestDispatcher(path, opts);
}
if (dispatcher != null) {
SlingHttpServletResponse response = new JspSlingHttpServletResponseWrapper(pageContext);
dispatch(dispatcher, request, response);
} else {
TagUtil.log(log, pageContext, "No content to include...", null);
}
} catch (final JspTagException jte) {
throw jte;
} catch (final IOException ioe) {
throw new JspTagException(ioe);
} catch (final ServletException ce) {
throw new JspTagException(TagUtil.getRootCause(ce));
}
return EVAL_PAGE;
}
use of javax.servlet.jsp.JspTagException in project spring-framework by spring-projects.
the class BindTag method doStartTagInternal.
@Override
protected final int doStartTagInternal() throws Exception {
String resolvedPath = getPath();
if (!isIgnoreNestedPath()) {
String nestedPath = (String) pageContext.getAttribute(NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
// only prepend if not already an absolute path
if (nestedPath != null && !resolvedPath.startsWith(nestedPath) && !resolvedPath.equals(nestedPath.substring(0, nestedPath.length() - 1))) {
resolvedPath = nestedPath + resolvedPath;
}
}
try {
this.status = new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape());
} catch (IllegalStateException ex) {
throw new JspTagException(ex.getMessage());
}
// Save previous status values, for re-exposure at the end of this tag.
this.previousPageStatus = pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
this.previousRequestStatus = pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
// Expose this tag's status object as PageContext attribute,
// making it available for JSP EL.
pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
pageContext.setAttribute(STATUS_VARIABLE_NAME, this.status, PageContext.REQUEST_SCOPE);
return EVAL_BODY_INCLUDE;
}
Aggregations