HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); String pageID = (String)request.getAttribute("pageID"); String subPageID = (String)request.getAttribute("subPageID"); JspWriter out = pageContext.getOut(); String body = getBodyContent().getString(); value = StringUtils.replace(value, "[id]", clean(tab.attributeValue("id"))); value = StringUtils.replace(value, "[url]", request.getContextPath() + "/" + clean(tab.attributeValue("url"))); value = StringUtils.replace(value, "[name]", clean(AdminConsole.getAdminText(tab.attributeValue("name"), pluginName))); out.write(buf.toString()); throw new JspException(ioe.getMessage());
/** * Returns the exception that caused this JSP exception. * * @return the <code>Throwable</code> * that caused this JSP exception * * @deprecated As of JSP 2.1, replaced by {@link #getCause()} */ public Throwable getRootCause() { return getCause(); } }
@Test public void withInvalidList() throws Exception { this.tag.setPath("country"); this.tag.setItems(new TestBean()); this.tag.setItemValue("isoCode"); try { this.tag.doStartTag(); fail("Must not be able to use a non-Collection typed value as the value of 'items'"); } catch (JspException expected) { String message = expected.getMessage(); assertTrue(message.contains("items")); assertTrue(message.contains("org.springframework.tests.sample.beans.TestBean")); } }
Integer.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); request.setAttribute("javax.servlet.error.request_uri", ((HttpServletRequest) request).getRequestURI()); request.setAttribute("javax.servlet.error.servlet_name", config.getServletName()); rootCause = ((JspException) t).getRootCause(); } else if (t instanceof ELException) { rootCause = t.getCause();
@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); } } }
/** * Expose a single header value. * @throws JspException * @since Struts 1.2 */ protected void handleSingleHeader() throws JspException { String value = ((HttpServletRequest) pageContext.getRequest()).getHeader(name); if ((value == null) && (this.value != null)) { value = this.value; } if (value == null) { JspException e = new JspException(messages.getMessage("header.get", name)); TagUtils.getInstance().saveException(pageContext, e); throw e; } pageContext.setAttribute(id, value); }
/** * Process the start of this tag. * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String serverName = (this.server == null) ? request.getServerName() : this.server; String baseTag = renderBaseElement( request.getScheme(), serverName, request.getServerPort(), request.getRequestURI()); JspWriter out = pageContext.getOut(); try { out.write(baseTag); } catch (IOException e) { pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE); throw new JspException(messages.getMessage("common.io", e.toString())); } return EVAL_BODY_INCLUDE; }
if (logger.isWarnEnabled()) { logger.warn("it is not in a rose request: '" + ((HttpServletRequest) pageContext.getRequest()).getRequestURI() + "'"); if (logger.isWarnEnabled()) { logger.warn("there is not pipe for this jsp: '" + ((HttpServletRequest) pageContext.getRequest()).getRequestURI() + "'"); logger.debug("writing " + pipe + "..."); pipe.write(pageContext.getOut()); throw new JspException(e);
@Override public int doEndTag() throws JspException { EvaluationContext evaluationContext = (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE); if (evaluationContext == null) { evaluationContext = createEvaluationContext(this.pageContext); this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext); } if (this.var != null) { Object result = (this.expression != null ? this.expression.getValue(evaluationContext) : null); this.pageContext.setAttribute(this.var, result, this.scope); } else { try { String result = (this.expression != null ? this.expression.getValue(evaluationContext, String.class) : null); result = ObjectUtils.getDisplayString(result); result = htmlEscape(result); result = (this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(result) : result); this.pageContext.getOut().print(result); } catch (IOException ex) { throw new JspException(ex); } } return EVAL_PAGE; }
public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); String path = request.getContextPath(); JspWriter out = pageContext.getOut(); try { out.write(path); out.write("/"); } catch (IOException e) { throw new JspException("Error writing tag content", e); } return EVAL_PAGE; } }
/** * Redirect to the given path converting exceptions to JspException. * @param path The path to redirect to. * @throws JspException * @since Struts 1.2 */ protected void doRedirect(String path) throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); try { if (path.startsWith("/")) { path = request.getContextPath() + path; } response.sendRedirect(response.encodeRedirectURL(path)); } catch (Exception e) { TagUtils.getInstance().saveException(pageContext, e); throw new JspException( messages.getMessage("forward.redirect", name, e.toString())); } }
/** * @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; }
UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext); if (tag == null) { // PENDING - i18n throw new JspException("Not nested in a UIComponentTag"); UIComponent component = tag.getComponentInstance(); if (component == null) { // PENDING - i18n throw new JspException("No component associated with UIComponentTag"); FacesContext context = FacesContext.getCurrentInstance(); ExpressionFactory exprFactory = context.getApplication().getExpressionFactory(); ELContext elContext = context.getELContext();
protected Validator createValidator() throws JspException { try { return createValidator(validatorId, binding, FacesContext.getCurrentInstance()); } catch (FacesException fe) { throw new JspException(fe.getCause()); } }
private static void write(PageContext pageContext, String s, boolean toEnclosingWriter) throws JspException { JspWriter writer = pageContext.getOut(); if(toEnclosingWriter && writer instanceof BodyContent) writer = ((BodyContent)writer).getEnclosingWriter(); try { writer.print(s); } catch(IOException e) { throw new JspException("Input/output error: " + e.toString()); } }
} 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);
return getFacesJspId(); } else { if (isDuplicateId(this.id)) { if (!isSpecifiedIdUnique(this.id)) { if (isNestedInIterator) { this.id = generateIncrementedId(this.id); } else { StringWriter writer = new StringWriter(128); printTree(context.getViewRoot(), this.id, writer, 0); String msg = "Component ID '" + this.id + " the detected error.\n" + writer.toString(); throw new JspException(msg);
/** * Performs smart form population. */ @Override public int doAfterBody() throws JspException { BodyContent body = getBodyContent(); JspWriter out = body.getEnclosingWriter(); String bodytext = populateForm(body.getString(), name -> value(name, pageContext)); try { out.print(bodytext); } catch (IOException ioex) { throw new JspException(ioex); } return SKIP_BODY; }
/** Invoked at the tag start transition; does the work */ public int doStartTag() throws JspException { if (userName == null) { throw new JspException("LoggedInUserTag requires the 'user' attribute"); } HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); return request.getRemoteUser().equals(userName) ? EVAL_BODY_INCLUDE : SKIP_BODY; }
public int doEndTag() throws JspException { try { String body = bodyContent.getString(); bodyContent.clearBody(); String link = getLoginLink((HttpServletRequest) pageContext.getRequest(), body); bodyContent.getEnclosingWriter().write(link); } catch (IOException e) { throw new JspException("IOException: " + e); } return super.doEndTag(); }