Example usage for javax.servlet.jsp JspException JspException

List of usage examples for javax.servlet.jsp JspException JspException

Introduction

In this page you can find the example usage for javax.servlet.jsp JspException JspException.

Prototype

public JspException(Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified cause.

Usage

From source file:de.micromata.genome.gwiki.web.tags.WikiLinkTag.java

@Override
public int doEndTag() throws JspException {
    // JspContext jc = getJspContext();
    final GWikiContext wctx = getWikiContext();
    if (StringUtils.isNotEmpty(titleKey) == true) {
        title = wctx.getWikiWeb().getI18nProvider().translate(wctx, titleKey);
    }/*www.  j  a v  a 2s  .  c o  m*/
    String url = wctx.renderLocalUrl(pageId, title, urlParams);
    try {
        pageContext.getOut().print(url);
    } catch (IOException ex) {
        throw new JspException(ex);
    }
    return EVAL_PAGE;
}

From source file:it.eng.spagobi.commons.presentation.tags.ErrorTag.java

/**
 * Do start tag.//from w  w  w. j  a  v  a  2 s.  c o m
 * 
 * @return the int
 * 
 * @throws JspException the jsp exception
 * 
 * @see it.eng.spagobi.commons.presentation.tags.ListTag#doStartTag()
 */
public int doStartTag() throws JspException {
    TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.DEBUG, "ErrorTag::doStartTag:: invoked");
    if (pageContext == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: pageContext null");
        throw new JspException("pageContext nullo");
    } // if (_httpRequest == null)
    HttpServletRequest httpRequest = null;
    try {
        httpRequest = (HttpServletRequest) pageContext.getRequest();
    } // try
    catch (Exception ex) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL, "ErrorTag::doStartTag::",
                ex);
        throw new JspException(ex.getMessage());
    } // catch (Exception ex)
    if (httpRequest == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: httpRequest null");
        throw new JspException("httpRequest nullo");
    } // if (_httpRequest == null)
      //ResponseContainer responseContainer = ResponseContainerPortletAccess.getResponseContainer(httpRequest);
    ResponseContainer responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    if (responseContainer == null) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL,
                "ErrorTag::doStartTag:: responseContainer null");
        throw new JspException("responseContainer null");
    } // if (responseContainer == null)
    StringBuffer output = new StringBuffer();
    EMFErrorHandler engErrorHandler = responseContainer.getErrorHandler();

    Collection errors = engErrorHandler.getErrors();

    if (!errors.isEmpty()) {
        output.append("<div class='errors-object-details-div'>\n");
        output.append("   <div class='div_detail_errors'>\n");
        output.append("      <div class='portlet-section-header'>\n");
        output.append("         ERRORS:\n");
        output.append("      </div>\n");
        output.append("      <div class='portlet-msg-error'>\n");
        output.append("         <ul class='ul_detail_error'>\n");
        EMFAbstractError error = null;
        String description = "";
        Iterator iter = errors.iterator();
        while (iter.hasNext()) {
            error = (EMFAbstractError) iter.next();
            description = error.getDescription();
            description = StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(description));
            output.append("         <li>" + description + "</li>\n");
        }
        output.append("         </ul>\n");
        output.append("      </div>\n");
        output.append("   </div>\n");
        output.append("</div>\n");
    }

    try {
        pageContext.getOut().print(output.toString());
    } // try
    catch (Exception ex) {
        TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.CRITICAL, "ErrorTag::doStartTag::",
                ex);
        throw new JspException(ex.getMessage());
    } // catch (Exception ex)
    return SKIP_BODY;
}

From source file:com.googlecode.spring.appengine.taglib.InstanceIdTag.java

@Override
public int doEndTag() throws JspException {
    Object instanceId = ApiProxy.getCurrentEnvironment().getAttributes()
            .get("com.google.appengine.instance.id");
    if (var == null) {
        try {/*  w  w  w .java2s  .c  om*/
            if (instanceId != null) {
                pageContext.getOut().print(instanceId);
            }
        } catch (IOException e) {
            throw new JspException(e);
        }
    } else {
        pageContext.setAttribute(var, instanceId, scope);
    }
    return Tag.EVAL_PAGE;
}

From source file:net.testdriven.psiprobe.jsp.ParamToggleTag.java

@Override
public int doStartTag() throws JspException {
    boolean getSize = ServletRequestUtils.getBooleanParameter(pageContext.getRequest(), param, false);
    StringBuffer query = new StringBuffer();
    query.append(param).append("=").append(!getSize);
    for (Enumeration en = pageContext.getRequest().getParameterNames(); en.hasMoreElements();) {
        String name = (String) en.nextElement();
        if (!param.equals(name)) {
            query.append("&").append(name).append("=")
                    .append(ServletRequestUtils.getStringParameter(pageContext.getRequest(), name, ""));
        }//from  w  w w .  j  av a2s.co m
    }
    try {
        pageContext.getOut().print(query);
    } catch (IOException e) {
        logger.debug("Exception printing query string to JspWriter", e);
        throw new JspException(e);
    }
    return EVAL_BODY_INCLUDE;
}

From source file:com.googlecode.spring.appengine.taglib.LoginUrlTag.java

@Override
public int doEndTag() throws JspException {
    String loginUrl = UserServiceFactory.getUserService().createLoginURL(destinationUrl, federatedIdentity);
    if (var == null) {
        try {// w  w w  .  jav a 2  s.co  m
            pageContext.getOut().print(loginUrl);
        } catch (IOException e) {
            throw new JspException(e);
        }
    } else {
        pageContext.setAttribute(var, loginUrl, scope);
    }
    return Tag.EVAL_PAGE;
}

From source file:net.sf.ginp.tags.GetContextName.java

/**
 *  Called when a Start tag is processed.
 *
 * @return                   Description of the Return Value
 * @exception  JspException  Description of the Exception
 *//*from  ww  w.j a va 2s. com*/
public final int doStartTag() throws JspException {
    try {
        pageContext.getOut().write(pageContext.getServletContext().getServletContextName());
    } catch (IOException ioe) {
        log.error(ioe);
        throw new JspException(ioe.getMessage());
    }

    return EVAL_BODY_INCLUDE;
}

From source file:psiprobe.jsp.AddQueryParamTag.java

@Override
public int doStartTag() throws JspException {
    StringBuilder query = new StringBuilder();
    query.append(param).append("=").append(value);
    for (String name : Collections.list(pageContext.getRequest().getParameterNames())) {
        if (!param.equals(name)) {
            query.append("&").append(name).append("=")
                    .append(ServletRequestUtils.getStringParameter(pageContext.getRequest(), name, ""));
        }//from  w  w w  .  jav a 2 s. c  o m
    }
    try {
        pageContext.getOut().print(query);
    } catch (IOException e) {
        logger.debug("Exception printing query string to JspWriter", e);
        throw new JspException(e);
    }
    return EVAL_BODY_INCLUDE;
}

From source file:edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils.java

/**
 * Gets an attribute from the request, if it is not null, and of Class String
 * print it to req.out, otherwise throw an exception.
 *
 * @param req/*from  ww w .j a v  a  2 s.  c  om*/
 * @param attribute
 */
public static String writeAttribute(HttpServletRequest request, String attribute) throws JspException {
    Object contentObj = request.getAttribute(attribute);
    if (contentObj == null)
        throw new JspException("Attribute " + attribute + " in request attributes was null.");
    if (!(contentObj instanceof String)) {
        String className = contentObj.getClass().getName();
        throw new JspException("Class of " + attribute + " is " + className + ", it should be String");
    }
    return (String) contentObj;
}

From source file:com.googlecode.psiprobe.jsp.ParamToggleTag.java

public int doStartTag() throws JspException {
    boolean getSize = ServletRequestUtils.getBooleanParameter(pageContext.getRequest(), param, false);
    StringBuffer query = new StringBuffer();
    query.append(param).append("=").append(!getSize);
    String encoding = pageContext.getResponse().getCharacterEncoding();
    for (Enumeration en = pageContext.getRequest().getParameterNames(); en.hasMoreElements();) {
        String name = (String) en.nextElement();
        if (!param.equals(name)) {
            try {
                String value = ServletRequestUtils.getStringParameter(pageContext.getRequest(), name, "");
                String encodedValue = URLEncoder.encode(value, encoding);
                query.append("&").append(name).append("=").append(encodedValue);
            } catch (UnsupportedEncodingException e) {
                throw new JspException(e);
            }//from  www.  j a va2 s  .  com
        }
    }
    try {
        pageContext.getOut().print(query);
    } catch (IOException e) {
        logger.debug("Exception printing query string to JspWriter", e);
        throw new JspException(e);
    }
    return EVAL_BODY_INCLUDE;
}