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:com.steeleforge.aem.ironsites.i18n.taglib.I18nHelperTag.java

public void setSource(String source) throws JspException {
    try {//from ww  w. j a v a 2 s .co m
        this.source = Source.valueOf(source.toUpperCase());
    } catch (IllegalArgumentException e) {
        LOG.error("Source must match: " + Arrays.toString(Source.values()), e.getMessage());
        throw new JspException(e);
    }
}

From source file:jp.terasoluna.fw.web.taglib.TagUtil.java

/**
 * PageContextJspWriter?AweLXg?o?B/* w ww . j a  v a2  s.c  o  m*/
 * ?s?B
 * 
 * @param pageContext y?[WReLXg
 * @param text ?oeLXg
 * @throws JspException
 * I/OG?[???IOExceptionbvO
 */
public static void write(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();
    try {
        writer.print(text);
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:com.geemvc.taglib.GeemvcTagSupport.java

protected void writeTag(JspWriter writer, String tagName, boolean hasTagBody, boolean closeTag)
        throws JspException {
    this.tagName = tagName;
    this.hasTagBody = hasTagBody;

    try {//from   ww  w.  j  a v  a 2s.c  om
        writer.write(Char.LESS_THAN);
        writer.write(tagName);
        appendTagAttributes(writer);
        writeTagAttributes(writer);

        if (hasTagBody) {
            writer.write(Char.GREATER_THAN);
            appendTagBody(writer);
        }

        if (closeTag)
            writeCloseTag(writer, tagName, hasTagBody);
    } catch (Throwable t) {
        throw new JspException(t);
    }
}

From source file:net.sourceforge.ajaxtags.tags.BaseAjaxBodyTag.java

protected void out(final CharSequence csec) throws JspException {
    try {//from  ww  w.j av  a  2s.  c om
        pageContext.getOut().append(csec);
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:com.xhsoft.framework.common.page.MiniPageTag.java

/**
 * <p>Description: build up goto text area and print</p>
 * @param request   //from   w  w  w .  j  ava2  s . co m
 * @param pageNo  
 * @param totalPages 
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void buildGoto(HttpServletRequest request, int pageNo, int totalPages) throws JspException {
    try {
        @SuppressWarnings("unused")
        JspWriter out = pageContext.getOut();
        if (StringUtils.isEmpty(pageSizeList)) {
            pageSizeList = INIT_PAGE_SIZE_LIST;
        }
        @SuppressWarnings("unused")
        String rand = UUID.randomUUID().toString();

    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:ch.entwine.weblounge.taglib.resource.FileResourceTag.java

/**
 * {@inheritDoc}//from  w  w w.ja va 2s .  co m
 * 
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
 */
@Override
public int doStartTag() throws JspException {

    // Don't do work if not needed (which is the case during precompilation)
    if (RequestUtils.isPrecompileRequest(request))
        return SKIP_BODY;

    Site site = request.getSite();

    ContentRepository repository = site.getContentRepository();
    if (repository == null) {
        logger.debug("Unable to load content repository for site '{}'", site);
        response.invalidate();
        return SKIP_BODY;
    }

    // Create the file uri, either from the id or the path. If none is
    // specified, issue a warning
    ResourceURI uri = null;
    if (StringUtils.isNotBlank(fileId)) {
        uri = new FileResourceURIImpl(site, null, fileId);
    } else if (StringUtils.isNotBlank(filePath)) {
        uri = new FileResourceURIImpl(site, filePath, null);
    } else {
        throw new JspException("Neither resource id nor resource path were specified");
    }

    // Try to load the file from the content repository
    try {
        if (!repository.exists(uri)) {
            logger.warn("Non existing file {} requested on {}", uri, request.getUrl());
            return SKIP_BODY;
        }
    } catch (ContentRepositoryException e) {
        logger.error("Error trying to look up file {} from {}", fileId, repository);
        return SKIP_BODY;
    }

    FileResource file = null;
    FileContent fileContent = null;

    // Determine the languages
    Language language = request.getLanguage();

    // Store the result in the jsp page context
    try {
        file = (FileResource) repository.get(uri);
        file.switchTo(language);

        Language contentLanguage = null;
        contentLanguage = LanguageUtils.getPreferredContentLanguage(file, request, site);
        if (contentLanguage == null) {
            logger.warn("File {} does not have suitable content", file);
            return SKIP_BODY;
        }

        fileContent = file.getContent(contentLanguage);
    } catch (ContentRepositoryException e) {
        logger.warn("Error trying to load file " + uri + ": " + e.getMessage(), e);
        return SKIP_BODY;
    }

    // TODO: Check the permissions

    // Store the file and the file content in the request
    stashAndSetAttribute(FileResourceTagExtraInfo.FILE, file);
    stashAndSetAttribute(FileResourceTagExtraInfo.FILE_CONTENT, fileContent);

    // Add cache tags to response
    response.addTag(CacheTag.Resource, file.getURI().getIdentifier());
    response.addTag(CacheTag.Url, file.getURI().getPath());

    return EVAL_BODY_INCLUDE;
}