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(String message, Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified detail message and cause.

Usage

From source file:com.agiletec.plugins.jpavatar.apsadmin.tags.AvatarTag.java

public int doEndTag() throws JspException {
    try {//from ww w.ja va2s.com
        IAvatarManager avatarManager = (IAvatarManager) ApsWebApplicationUtils
                .getBean(JpAvatarSystemConstants.AVATAR_MANAGER, pageContext);
        HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
        UserDetails currentUser = (UserDetails) request.getSession()
                .getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);

        boolean isCurrentUserGuest = null == currentUser || currentUser.getUsername().trim().length() == 0
                || currentUser.getUsername().equalsIgnoreCase(SystemConstants.GUEST_USER_NAME);
        if (StringUtils.isBlank(this.getUsername()) && isCurrentUserGuest) {
            this.doOut(this.getNullAvatar(avatarManager));
        } else {
            String username = this.getUsername();
            if (StringUtils.isBlank(username)) {
                username = currentUser.getUsername();
            }
            String avatarName = avatarManager.getAvatarUrl(username);
            if (null != avatarName) {
                this.doOut(avatarName);
            } else {
                this.doOut(this.getNullAvatar(avatarManager));
            }
        }
        if (StringUtils.isNotBlank(this.getAvatarStyleVar())) {
            this.pageContext.getRequest().setAttribute(this.getAvatarStyleVar(),
                    avatarManager.getConfig().getStyle());
        }
    } catch (Throwable e) {
        ApsSystemUtils.logThrowable(e, this, "doEndTag");
        throw new JspException("Error in AvatarTag", e);
    }
    return EVAL_PAGE;
}

From source file:com.agiletec.aps.tags.CheckPermissionTag.java

@Override
public int doStartTag() throws JspException {
    HttpSession session = this.pageContext.getSession();
    try {//www . j av a  2  s.c o  m
        boolean isAuthorized = false;
        UserDetails currentUser = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
        IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils
                .getBean(SystemConstants.AUTHORIZATION_SERVICE, this.pageContext);
        boolean isGroupSetted = StringUtils.isNotEmpty(this.getGroupName());
        boolean isPermissionSetted = StringUtils.isNotEmpty(this.getPermission());
        boolean isAuthGr = isGroupSetted && (authManager.isAuthOnGroup(currentUser, this.getGroupName())
                || authManager.isAuthOnGroup(currentUser, Group.ADMINS_GROUP_NAME));
        boolean isAuthPerm = isPermissionSetted
                && (authManager.isAuthOnPermission(currentUser, this.getPermission())
                        || authManager.isAuthOnPermission(currentUser, Permission.SUPERUSER));
        if (isGroupSetted && !isPermissionSetted) {
            isAuthorized = isAuthGr;
        } else if (!isGroupSetted && isPermissionSetted) {
            isAuthorized = isAuthPerm;
        } else if (isGroupSetted && isPermissionSetted && isAuthGr && isAuthPerm) {
            isAuthorized = authManager.isAuthOnGroupAndPermission(currentUser, this.getGroupName(),
                    this.getPermission(), true);
        }
        if (null != this.getVar()) {
            this.pageContext.setAttribute(this.getVar(), isAuthorized);
        }
        if (isAuthorized) {
            return EVAL_BODY_INCLUDE;
        } else {
            return SKIP_BODY;
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization ", t);
    }
}

From source file:com.agiletec.aps.tags.ExecWidgetTag.java

/**
 * Invoke the widget configured in the page.
 *
 * @throws JspException In case of errors in this method or in the included
 * JSPs/*from  w w w  .  j a  va  2  s .co m*/
 */
@Override
public int doEndTag() throws JspException {
    ServletRequest req = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
    try {
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_HEAD_INFO_CONTAINER, new HeadInfoContainer());
        IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        String[] widgetOutput = new String[page.getWidgets().length];
        reqCtx.addExtraParam("ShowletOutput", widgetOutput);
        this.buildWidgetOutput(page, widgetOutput);
        String redirect = (String) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXTERNAL_REDIRECT);
        if (null != redirect) {
            HttpServletResponse response = (HttpServletResponse) this.pageContext.getResponse();
            response.sendRedirect(redirect);
            return SKIP_PAGE;
        }
        this.pageContext.popBody();
    } catch (Throwable t) {
        String msg = "Error detected during widget preprocessing";
        ApsSystemUtils.logThrowable(t, this, "doEndTag", msg);
        throw new JspException(msg, t);
    }
    return super.doEndTag();
}

From source file:com.stratelia.webactiv.util.viewGenerator.html.result.HtmlSearchResultTag.java

@Override
public int doStartTag() throws JspException {
    try {//from   www. j  av a  2s  .  c  o m
        pageContext.getOut().print(getHtmlResult());
    } catch (IOException ex) {
        throw new JspException("Silverpeas Java to html paragraph Converter Tag", ex);
    }
    return EVAL_PAGE;
}

From source file:org.shredzone.cilla.web.tag.RenderTag.java

@Override
public int doEndTag() throws JspException {
    try {//from  w  ww . j av a 2 s  .c  om
        if (rendered != null && rendered.booleanValue() == false) {
            return EVAL_PAGE;
        }

        if (optional != null && optional.booleanValue() == true) {
            if (!fragmentService.hasFragment(fragment)) {
                // Fragment is optional and does not exist
                return EVAL_PAGE;
            }
        }

        String result;
        try {
            result = fragmentService.renderFragment(fragment, context);
            if (result != null) {
                pageContext.getOut().print(result);
            }
        } catch (CillaServiceException | IOException ex) {
            throw new JspException("Failed to render fragment " + fragment, ex);
        }

        return EVAL_PAGE;
    } finally {
        context = null;
    }
}

From source file:com.agiletec.plugins.jpblog.aps.tags.BlogCategoryTag.java

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    IBlogManager blogManager = (IBlogManager) ApsWebApplicationUtils.getBean(JpblogSystemConstants.BLOG_MANAGER,
            this.pageContext);
    try {/*  w w w .  j  a  v  a 2 s.  co  m*/
        if (null == this.getTypeCode())
            this.setTypeCode(this.extractContentType());
        List<String> userGroupCodes = new ArrayList<String>(this.getAllowedGroups(reqCtx));
        //List<String> facetNodeCodes = blogManager.getSpecialCategories();
        List<String> contentTypeCodes = new ArrayList<String>();
        contentTypeCodes.add(this.getTypeCode());

        Map<Category, Integer> blogCategories = blogManager.getOccurrences(contentTypeCodes, userGroupCodes);
        //this.pageContext.setAttribute(this.getVar(), blogCategories);
        this.pageContext.setAttribute(this.getVar(), this.buildCategoryInfoBeanList(blogCategories));
    } catch (Throwable t) {
        _logger.error("error in doEndTag", t);
        throw new JspException("Error closing tag ", t);
    }
    this.release();
    return EVAL_PAGE;
}

From source file:com.agiletec.plugins.jpcrowdsourcing.aps.tags.CrowdsourcingStatisticTag.java

@Override
public int doEndTag() throws JspException {
    try {// w ww . j  ava  2s  .  c  o  m
        IIdeaManager ideaManager = (IIdeaManager) ApsWebApplicationUtils
                .getBean(JpCrowdSourcingSystemConstants.IDEA_MANAGER, this.pageContext);
        StatisticInfoBean statisticInfoBean = null;
        if (StringUtils.isNotBlank(this.getInstanceCode())) {
            statisticInfoBean = ideaManager.getActiveIdeaStatistics(this.getInstanceCode());
        } else {
            UserDetails currentUser = (UserDetails) pageContext.getSession()
                    .getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
            if (currentUser == null) {
                IUserManager userManager = (IUserManager) ApsWebApplicationUtils
                        .getBean(SystemConstants.USER_MANAGER, pageContext);
                currentUser = userManager.getGuestUser();
            }
            IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils
                    .getBean(SystemConstants.AUTHORIZATION_SERVICE, pageContext);
            List<Group> groups = authManager.getUserGroups(currentUser);
            List<String> groupsColl = new ArrayList<String>();
            if (null != groups) {
                for (int i = 0; i < groups.size(); i++) {
                    groupsColl.add(groups.get(i).getName());
                }
            }
            if (!groupsColl.contains(Group.FREE_GROUP_NAME))
                groupsColl.add(Group.FREE_GROUP_NAME);
            statisticInfoBean = ideaManager.getActiveIdeaStatistics(groupsColl);
        }
        this.pageContext.setAttribute(this.getVar(), statisticInfoBean);
    } catch (Throwable t) {
        _logger.error("error in doEndTag", t);
        throw new JspException("Errore tag", t);
    }
    this.release();
    return super.doEndTag();
}

From source file:com.agiletec.plugins.jpcrowdsourcing.aps.tags.CurrentPageWidgetTag.java

@Override
public int doStartTag() throws JspException {
    try {// w ww  .j  a va 2 s. c  om
        Widget showlet = this.extractShowlet();
        if (null == showlet)
            return super.doStartTag();
        String value = null;
        if ("code".equals(this.getParam())) {
            value = showlet.getType().getCode();
        } else if ("title".equals(this.getParam())) {
            value = this.extractTitle(showlet);
        } else if ("config".equals(this.getParam())) {
            ApsProperties config = showlet.getConfig();
            if (null != config) {
                value = config.getProperty(this.getConfigParam());
            }
        }
        if (null != value) {
            String var = this.getVar();
            if (null == var || "".equals(var)) {
                if (this.getEscapeXml()) {
                    out(this.pageContext, this.getEscapeXml(), value);
                } else {
                    this.pageContext.getOut().print(value);
                }
            } else {
                this.pageContext.setAttribute(this.getVar(), value);
            }
        }
    } catch (Throwable t) {
        String msg = "Error detected during showlet preprocessing";
        _logger.error("error in doEndTag", t);
        throw new JspException(msg, t);
    }
    return super.doStartTag();
}

From source file:org.toobsframework.taglib.ComponentRef.java

public int doEndTag() throws JspException {

    ComponentTransformerHelper transformerHelper = (ComponentTransformerHelper) beanFactory
            .getBean(this.transformerHelper);

    UrlDispatchInfo dispatchInfo = new UrlDispatchInfo("jsptag:" + componentId, componentId, "xhtml");
    //Setup Component Request
    transformerHelper.getComponentRequestManager().set(dispatchInfo,
            (HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse(),
            parameterMap, false);/* w ww .j  a  va  2 s.c  o m*/

    IRequest request = transformerHelper.getComponentRequestManager().get();
    if (dataObject != null && dataObjectName != null) {
        request.putParam(dataObjectName, dataObject);
    }

    //Find component
    org.toobsframework.pres.component.Component component = null;
    try {
        component = transformerHelper.getComponentManager().getComponent(componentId);
    } catch (ComponentNotFoundException e) {
        throw new JspException("Could not find component with Id:" + componentId, e);
    } catch (ComponentInitializationException e) {
        throw new JspException("Could not initialize component with Id:" + componentId, e);
    }

    //Render Component
    if (contentType == null || contentType.length() == 0) {
        contentType = "xhtml";
    }
    String output = "";
    try {
        output = transformerHelper.getComponentManager().renderComponent(request, component, contentType,
                transformerHelper.getComponentRequestManager().get().getParams(),
                transformerHelper.getComponentRequestManager().get().getParams(), transformerHelper, true);
    } catch (ComponentNotInitializedException e) {
        throw new JspException("Component with Id:" + componentId + ": is not intitialized.", e);
    } catch (ComponentException e) {
        throw new JspException("Could not render component with Id:" + componentId, e);
    } catch (ParameterException e) {
        throw new JspException("Could not resolve parameters for component with Id:" + componentId, e);
    } catch (IOException e) {
        throw new JspException("Could not render component with Id:" + componentId, e);
    } finally {
        transformerHelper.getComponentRequestManager().unset();
    }

    //Now output results
    try {
        pageContext.getOut().write(output);
    } catch (IOException e) {
        throw new JspException("Could not output result for component with Id:" + componentId, e);
    }

    return EVAL_PAGE;
}

From source file:net.jcreate.e3.tree.taglib.TreeTag.java

private void setProperty(Object pObj, String pProperty, Object pValue) throws JspException {
    try {//from   w w w . j a  v a  2 s  . com
        BeanUtils.setProperty(pObj, pProperty, pValue);
    } catch (Exception ex) {
        final String msg = "" + pObj.getClass().getName() + ":" + pProperty
                + "?" + ":" + pValue;
        logger.error(msg, ex);
        throw new JspException(msg, ex);
    }

}