@SuppressWarnings({"unchecked"}) public int onDoStartTag() throws JspException { String strValue = null; if (getSubject() != null) { // Get the principal to print out Object principal; if (type == null) { principal = getSubject().getPrincipal(); } else { principal = getPrincipalFromClassName(); } // Get the string value of the principal if (principal != null) { if (property == null) { strValue = principal.toString(); } else { strValue = getPrincipalProperty(principal, property); } } } // Print out the principal value if not null if (strValue != null) { try { pageContext.getOut().write(strValue); } catch (IOException e) { throw new JspTagException("Error writing [" + strValue + "] to JSP.", e); } } return SKIP_BODY; }
(HttpServletRequest) pageContext.getRequest(); if (context == null) { if (url.startsWith("/")) return (request.getContextPath() + url); else return url; } else { if (!context.startsWith("/") || !url.startsWith("/")) { throw new JspTagException( "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
public int doEndTag( ) throws javax.servlet.jsp.JspTagException { try { final HttpServletRequest req = ( HttpServletRequest ) pageContext.getRequest(); if ( req.getAttribute( "autoFocusHasBeenSet" ) == null ) { pageContext.getOut().write( "autofocus=\"autofocus\" " ); req.setAttribute( "autoFocusHasBeenSet", true ); } } catch ( Exception e ) { throw new JspTagException( e.getMessage() ); } return EVAL_PAGE; } }
sqlStatement = bodyContent.getString(); throw new JspTagException( Resources.getMessage("SQL_NO_STATEMENT")); throw new JspException(sqlStatement + ": " + e.getMessage(), e); pageContext.setAttribute(var, Integer.valueOf(result), scope); return EVAL_PAGE;
} else { if (bodyContent != null && bodyContent.getString() != null) input = bodyContent.getString().trim(); pageContext.removeAttribute(var, scope); false); if (loc == null) { throw new JspException( Resources.getMessage("PARSE_NUMBER_NO_PARSE_LOCALE")); parsed = parser.parse(input); } catch (ParseException pe) { throw new JspException( Resources.getMessage("PARSE_NUMBER_PARSE_ERROR", input), pe); pageContext.setAttribute(var, parsed, scope); } else { try { pageContext.getOut().print(parsed); } catch (IOException ioe) { throw new JspTagException(ioe.toString(), ioe);
public int doEndTag() throws JspException { if (bodyContent != null) { try { pageContext.getOut().print(bodyContent.getString()); } catch (IOException ioe) { throw new JspTagException(ioe.toString(), ioe); } } return EVAL_PAGE; }
public int doStartTag() throws JspException { initServices(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String returnValue = staticAssetService.convertAssetPath(value, request.getContextPath(), isRequestSecure()); if (var != null) { pageContext.setAttribute(var, returnValue); } else { try { pageContext.getOut().print(returnValue); } catch (IOException ioe) { throw new JspTagException(ioe.toString(), ioe); } } return EVAL_PAGE; }
@Override public int doStartTag() throws JspException { JspWriter out = pageContext.getOut(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); Form form = (Form)request.getAttribute("form"); if (form != null) { try { out.print(form.getFormDefinition()); } catch (IOException e) { log.error("", e); throw new JspTagException(getClass().getName() + ":" + e.getMessage()); } } return SKIP_BODY; } }
public int doEndTag( ) throws javax.servlet.jsp.JspTagException { try { final HttpServletRequest req = ( HttpServletRequest ) pageContext.getRequest(); pageContext.getOut().write( req.getContextPath() ); } catch ( Exception e ) { throw new JspTagException( e.getMessage() ); } return EVAL_PAGE; } }
/** * @see javax.servlet.jsp.tagext.Tag#doStartTag() */ @Override public int doStartTag() throws JspException { // get a reference to the parent "content container" class Tag ancestor = findAncestorWithClass(this, I_CmsXmlContentContainer.class); if (ancestor == null) { CmsMessageContainer errMsgContainer = Messages.get().container(Messages.ERR_PARENTLESS_TAG_1, "contentshow"); String msg = Messages.getLocalizedMessage(errMsgContainer, pageContext); throw new JspTagException(msg); } I_CmsXmlContentContainer contentContainer = (I_CmsXmlContentContainer)ancestor; // now get the content element value to display String content = contentShowTagAction(contentContainer, pageContext, getElement(), m_locale); try { if (content != null) { pageContext.getOut().print(content); } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_JSP_BEAN_0), e); } throw new JspException(e); } return SKIP_BODY; }
public int doEndTag() throws JspException { if (value == null || Utils.isProtocolURL(value.toLowerCase().trim())) { LOGGER.trace("Invalid url : {}", value); return gracefully(); } if (context == null) { HttpServletRequest httpServletRequest = (HttpServletRequest) pageContext.getRequest(); context = httpServletRequest.getContextPath(); } if ((!context.startsWith("/") || !value.startsWith("/")) && value.endsWith("/")) { LOGGER.warn("Invalid context|value."); throw new JspTagException("Invalid context|value"); } //We got the url, now suffix the fingerprint to it, right before . String eTag = Utils.buildETagForResources(Utils.findResourcesToMerge(context, value), pageContext.getServletContext()); value = Utils.addFingerPrint(eTag, value); value = context + "/" + value; value = value.replaceAll("/+", "/"); return gracefully(); }
public int doStartTag() throws JspException { try { HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); ContentManagementService cms = new ContentManagementService(request); List content = cms.getContentListForApproval(); request.setAttribute(name, content); } catch (Exception e) { log.error("", e); throw new JspTagException(e); } return SKIP_BODY; }
} else { if (dataSourceSpecified) { throw new JspException( Resources.getMessage("SQL_DATASOURCE_NULL")); throw new JspTagException( Resources.getMessage("DRIVER_INVALID_CLASS", e.toString()), e); pageContext.setAttribute(var, ds, scope); } else { Config.set(pageContext, Config.SQL_DATA_SOURCE, ds, scope);
BodyContent content = getBodyContent(); if (content != null) { msgid = content.getString().trim(); content.clearBody(); throw new JspTagException("No message given in TranslationTag"); pageContext.getOut().print(msg); } catch (IOException ex) { throw new JspException(ex);
@Override protected final int doStartTagInternal() throws Exception { String resolvedPath = getPath(); if (!isIgnoreNestedPath()) { String nestedPath = (String) this.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 = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE); this.previousRequestStatus = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE); // Expose this tag's status object as PageContext attribute, // making it available for JSP EL. this.pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE); this.pageContext.setAttribute(STATUS_VARIABLE_NAME, this.status, PageContext.REQUEST_SCOPE); return EVAL_BODY_INCLUDE; }
/** * Create and expose the current RequestContext. * Delegates to {@link #doStartTagInternal()} for actual work. * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE * @see org.springframework.web.servlet.support.JspAwareRequestContext */ @Override public final int doStartTag() throws JspException { try { this.requestContext = (RequestContext) this.pageContext.getAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE); if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } return doStartTagInternal(); } catch (JspException | RuntimeException ex) { logger.error(ex.getMessage(), ex); throw ex; } catch (Exception ex) { logger.error(ex.getMessage(), ex); throw new JspTagException(ex.getMessage()); } }
@Override public int doEndTag() throws JspException { try { JspWriter out = pageContext.getOut(); out.print("</select>"); } catch (Exception ex) { throw new JspTagException(ex.getMessage()); } return EVAL_PAGE; } }
public int doAfterBody() throws JspException { try { SimpleDateFormat format = new SimpleDateFormat(body.getString()); format.setTimeZone(TimeZone.getTimeZone(tz)); body.getEnclosingWriter().write(format.format(new Date())); return SKIP_BODY; } catch (Exception ex) { ex.printStackTrace(); throw new JspTagException(ex.toString()); } }
public int doAfterBody() throws JspException { if (bodyContent != null) { try { JspWriter out = getPreviousOut(); out.print(bodyContent.getString()); bodyContent.clearBody(); } catch (Exception ex) { ex.printStackTrace(); throw new JspTagException("Exception:: "+toString(ex)); } return (EVAL_BODY_BUFFERED); } return (SKIP_BODY); } public int doEndTag()
public int doAfterBody() throws JspException { boolean hasSection = pageContext.getAttribute("kantega_template_" + id, PageContext.REQUEST_SCOPE) != null; boolean negate = this.negate != null && this.negate.equals("true"); try { if((hasSection && ! negate) || (!hasSection && negate)) { bodyContent.writeOut(getPreviousOut()); } } catch (IOException e) { log.error("Error writing content", e); throw new JspTagException("HasSectionTag", e); } finally { bodyContent.clearBody(); } return SKIP_BODY; }