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.googlecode.jtiger.modules.ecside.tag.TrTag.java

public int doStartTag() throws JspException {
    try {// ww w .  ja v  a 2  s.com
        model = TagUtils.getModel(this);
        trBean = new Tr(model);
        trBean.setId(TagUtils.evaluateExpressionAsString("id", id, this, pageContext));
        trBean.setName(TagUtils.evaluateExpressionAsString("name", name, this, pageContext));
        trBean.setOnclick(TagUtils.evaluateExpressionAsString("onclick", onclick, this, pageContext));
        trBean.setOndblclick(TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));
        trBean.setOnmouseout(TagUtils.evaluateExpressionAsString("onmouseout", onmouseout, this, pageContext));
        trBean.setOnmouseover(
                TagUtils.evaluateExpressionAsString("onmouseover", onmouseover, this, pageContext));

        trBean.setTagAttributes(TagUtils.evaluateExpressionAsString(TableConstants.TAG_ATTRIBUTES,
                this.tagAttributes, this, pageContext));
        trBean.setStyle(TagUtils.evaluateExpressionAsString("style", style, this, pageContext));
        trBean.setStyleClass(TagUtils.evaluateExpressionAsString("styleClass", styleClass, this, pageContext));

    } catch (Exception e) {
        throw new JspException("TrTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e));
    }

    return EVAL_BODY_INCLUDE;
}

From source file:com.tecapro.inventory.common.tag.MSRadioTag.java

@Override
public int doStartTag() throws JspException {

    try {//  w w  w  .j  av a  2s. co  m
        TilesInfoValue tilesValue = (TilesInfoValue) pageContext
                .getAttribute(TilesInfoValue.class.getSimpleName(), PageContext.REQUEST_SCOPE);

        BaseForm form = (BaseForm) pageContext.getRequest().getAttribute(BaseForm.class.getSimpleName());

        tilesValue.setInfo(form.getValue().getInfo());

        if (getDisabled() && getValue().equals(BeanUtils.getProperty(form, getProperty()))) {
            setDisabled(false);
        }

        if (tilesValue.isReadonly()) {
            setDisabled(true);
        }

        area = (area == null || "".equals(area)) ? Constants.COMMON_AREA : area;
        if (!keyExistTed(getProperty(), form.getValue().getInfo().getItem().getAreaList(area))) {
            HashMap<String, Boolean> keyMap = new HashMap<String, Boolean>();
            keyMap.put(getProperty(), isRequire());
            form.getValue().getInfo().getItem().getAreaList(area).add(keyMap);
        }

        StringBuffer colorClass = new StringBuffer();

        if (isRequire()) {
            colorClass.append(Constants.StyleClass.REQUIRE);
            colorClass.append(Constants.SPACE);
        }

        List<String> idList = form.getError().getIdList();

        for (String id : idList) {
            if (id.equals(getProperty())) {
                colorClass.append(Constants.StyleClass.ERROR);
                colorClass.append(Constants.SPACE);
                break;
            }
        }

        if (colorClass.length() > 0) {
            MSTagUtil.addStyleClass(this, colorClass.toString());
        }

        MSTagUtil.setChangeFlag(this);

        return super.doStartTag();

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

From source file:com.ultrapower.eoms.common.plugin.ecside.tag.TrTag.java

 @Override
public int doStartTag() throws JspException {
     try {//from  w  w w.  j  ava2  s .  c  om
        model = TagUtils.getModel(this);
           trBean=new Tr(model);
           trBean.setId(TagUtils.evaluateExpressionAsString("id", id, this, pageContext));
           trBean.setName(TagUtils.evaluateExpressionAsString("name", name, this, pageContext));
            trBean.setOnclick(TagUtils.evaluateExpressionAsString("onclick", onclick, this, pageContext));
            trBean.setOndblclick(TagUtils.evaluateExpressionAsString("ondblclick", ondblclick, this, pageContext));
            trBean.setOnmouseout(TagUtils.evaluateExpressionAsString("onmouseout", onmouseout, this, pageContext));
            trBean.setOnmouseover(TagUtils.evaluateExpressionAsString("onmouseover", onmouseover, this, pageContext));
                
            trBean.setTagAttributes(TagUtils.evaluateExpressionAsString(TableConstants.TAG_ATTRIBUTES, this.tagAttributes, this, pageContext));
             trBean.setStyle(TagUtils.evaluateExpressionAsString("style", style, this, pageContext));
             trBean.setStyleClass(TagUtils.evaluateExpressionAsString("styleClass", styleClass, this, pageContext));

                
     } catch (Exception e) {
         throw new JspException("TrTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e));
     }
        
     return EVAL_BODY_INCLUDE;
 }

From source file:com.sun.faces.taglib.jsf_core.ViewTag.java

public int doStartTag() throws JspException {
    int rc = 0;//w w w  .j  a va  2  s . c o  m
    try {
        rc = super.doStartTag();
    } catch (JspException e) {
        if (log.isDebugEnabled()) {
            log.debug("Can't leverage base class", e);
        }
        throw e;
    } catch (Throwable t) {
        if (log.isDebugEnabled()) {
            log.debug("Can't leverage base class", t);
        }
        throw new JspException(t);
    }

    FacesContext facesContext = FacesContext.getCurrentInstance();
    Util.doAssert(facesContext != null);

    // this must happen after our overriderProperties executes.
    pageContext.getResponse().setLocale(facesContext.getViewRoot().getLocale());

    ResponseWriter writer = facesContext.getResponseWriter();
    Util.doAssert(writer != null);

    try {
        writer.startDocument();
    } catch (IOException e) {
        throw new JspException(e.getMessage());
    }
    return rc;
}

From source file:net.mlw.vlh.web.tag.DefaultSelectTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
 *//* w w  w.ja v a  2s . c om*/
public int doEndTag() throws JspException {
    ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);

    ValueList valueList = rootTag.getValueList();

    StringBuffer sb = new StringBuffer();

    sb.append("<select name=").append("'").append(name).append("'").append(attributes).append(">");

    if (bodyContent != null && bodyContent.getString() != null) {
        sb.append(bodyContent.getString());
    }

    try {
        String[] svalues = pageContext.getRequest().getParameterValues(name);
        List values = (svalues == null) ? Collections.EMPTY_LIST : Arrays.asList(svalues);

        for (Iterator iter = valueList.getList().iterator(); iter.hasNext();) {
            Object bean = iter.next();
            String value = BeanUtils.getProperty(bean, this.value);

            sb.append("<option ");
            if (values.contains(value)) {
                sb.append("selected='true' ");
            }
            sb.append("value='").append(value).append("'>");
            sb.append(BeanUtils.getProperty(bean, text));
            sb.append("</option>");
        }
    } catch (Exception e) {
        LOGGER.error("DefaultSelectTag.doEndTag() exception...", e);
        throw new JspException(e);
    }
    sb.append("</select>");

    JspUtils.write(pageContext, sb.toString());

    release();

    return EVAL_PAGE;
}

From source file:net.sibcolombia.portal.web.tag.AlphabetLinkTag.java

void addLink(StringBuffer sb, String contextPath, char letter, String displayedChar) throws JspException {
    sb.append("<a href=\"");
    sb.append(contextPath);/*from  w w  w  . jav  a  2 s  . co m*/
    sb.append(rootUrl);
    try {
        sb.append(URLEncoder.encode(String.valueOf(letter), "UTF-8"));
    } catch (Exception e) {
        throw new JspException(e);
    }
    sb.append("\" class=\"");
    sb.append(linkClass);
    sb.append("\">");
    sb.append(displayedChar);
    sb.append("</a>");
}

From source file:com.wabacus.system.tags.component.ButtonTag.java

public int doMyStartTag() throws JspException, IOException {
    type = type == null ? "" : type.trim().toLowerCase();
    name = name == null ? "" : name.trim();
    savebinding = savebinding == null ? "" : savebinding.trim();
    deletebinding = deletebinding == null ? "" : deletebinding.trim();
    if (!name.equals("") && !type.equals("")) {
        log.warn("<wx:button/>?nametype?name");
    } else if (name.equals("") && type.equals("")) {
        throw new JspException(
                "?typename?");
    }//from   w ww  .  jav a 2s . com
    return EVAL_BODY_BUFFERED;
}

From source file:edu.cornell.mannlib.vedit.tags.DynamicFieldsTag.java

public void parseMarkup() throws JspException {
    try {//from w w w  .j ava2 s.  co  m

        int preStart = -1;
        int templateStart = -1;
        int postStart = -1;

        InputStream fis = new FileInputStream(pageContext.getServletContext().getRealPath(new String())
                + PATH_SEP + MARKUP_FILE_PATH + usePage);
        InputStream bis = new BufferedInputStream(fis);
        BufferedReader in = new BufferedReader(new InputStreamReader(bis));
        List<String> lines = new ArrayList<String>();
        lines.add(""); // 0th line
        int lineIndex = 0;
        while (in.ready()) {
            ++lineIndex;
            String currentLine = in.readLine();
            if (currentLine != null && currentLine.indexOf("<!--") == 0 && currentLine.indexOf("@pre") > 0) {
                preStart = lineIndex;
            } else if (currentLine != null && currentLine.indexOf("<!--") == 0
                    && currentLine.indexOf("@template") > 0) {
                templateStart = lineIndex;
            } else if (currentLine != null && currentLine.indexOf("<!--") == 0
                    && currentLine.indexOf("@post") > 0) {
                postStart = lineIndex;
            }
            lines.add(currentLine);
        }
        in.close();

        StringBuffer preMarkupB = new StringBuffer();
        StringBuffer postMarkupB = new StringBuffer();
        StringBuffer templateMarkupB = new StringBuffer();

        if (templateStart > preStart && preStart > 0) {
            for (int i = preStart + 1; i < templateStart; i++) {
                preMarkupB.append(lines.get(i)).append("\n");
            }
        } else {
            System.out.println("DynamicFieldsTag could not find @pre markup in " + MARKUP_FILE_PATH + usePage);
            throw new JspException("DynamicFieldsTag could not parse @pre markup section");
        }
        preMarkup = preMarkupB.toString();

        if (postStart > templateStart && templateStart > 0) {
            for (int i = templateStart + 1; i < postStart; i++) {
                templateMarkupB.append(lines.get(i)).append("\n");
            }
        } else {
            System.out.println(
                    "DynamicFieldsTag could not find @template markup in " + MARKUP_FILE_PATH + usePage);
            throw new JspException("DynamicFieldsTag could not parse @template markup section");
        }
        templateMarkup = templateMarkupB.toString();

        if (postStart > 0) {
            for (int i = postStart + 1; i < lines.size(); i++) {
                postMarkupB.append(lines.get(i)).append("\n");
            }
        } else {
            System.out.println("DynamicFieldsTag could not find @post markup in " + MARKUP_FILE_PATH + usePage);
            throw new JspException("DynamicFieldsTag could not parse @post markup section");
        }
        postMarkup = postMarkupB.toString();

    } catch (FileNotFoundException e) {
        System.out.println("DynamicFieldsTag could not find markup file at "
                + pageContext.getServletContext().getRealPath(new String()) + "\\" + MARKUP_FILE_PATH
                + usePage);
    } catch (IOException ioe) {
        System.out.println("DynamicFieldsTag encountered IOException reading "
                + pageContext.getServletContext().getRealPath(new String()) + "\\" + MARKUP_FILE_PATH
                + usePage);
    }

}

From source file:com.trenako.web.tags.ActivityTags.java

@Override
protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException {

    StringBuilder sb = new StringBuilder();

    Account user = users().findBySlug(activity().getActor());

    String slug = user == null ? activity().getActor() : user.getSlug();
    String displayName = user == null ? activity().getActor() : user.getDisplayName();
    sb.append("\n<a href=\"").append(contextPath).append("/users/").append(slug).append("\">")
            .append(displayName).append("</a>");

    LocalizedEnum<ActivityVerb> verb = LocalizedEnum.parseString(activity().getVerb(), messageSource(),
            ActivityVerb.class);
    sb.append(" ").append(verb.getLabel()).append(" ");

    String objectName = activity().getObject().getDisplayName();
    String objectUrl = activity().getObject().getUrl();

    sb.append("\n<a href=\"").append(contextPath).append(objectUrl).append("\">").append(objectName)
            .append("</a>");

    if (activity().getContext() != null) {
        String contextMsg = "activitycontext." + activity().getContext().getContextType() + ".label";
        String contextLabel = messageSource().getMessage(contextMsg, null, contextMsg,
                getRequestContext().getLocale());

        sb.append(" ").append(contextLabel);
    }/*ww w .  ja v a  2 s.co  m*/

    Pair<String, Integer> p = periodUntilNow(activity().getRecorded());
    String periodText = messageSource().getMessage(p.getKey(), new Object[] { p.getValue() }, p.getKey(),
            getRequestContext().getLocale());

    sb.append("\n<br/><strong>").append(periodText).append("</strong>");

    try {
        jspWriter.append(sb.toString());
    } catch (IOException e) {
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:com.jdon.strutsutil.taglib.MPageTag.java

/**
 * Render the beginning of the hyperlink.
 *
 * @exception JspException if a JSP exception has occurred
 *//*w  ww . jav a2 s  .c om*/
public int doStartTag() throws JspException {

    // Generate the URL to be encoded
    ModuleConfig config = (ModuleConfig) pageContext.getRequest()
            .getAttribute(org.apache.struts.Globals.MODULE_KEY);

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String pageUrl = calculateURL();

    if (StringUtils.isNotBlank(pageUrl)) {
        try {
            String dh = "dh89001";
            String wh = "wh89001";
            String yh = "yh89001";
            String xg = "xg89001";
            pageUrl = VeStr.Replace(pageUrl, "=", dh);
            pageUrl = VeStr.Replace(pageUrl, "?", wh);
            pageUrl = VeStr.Replace(pageUrl, "&", yh);
            pageUrl = VeStr.Replace(pageUrl, "/", xg);

            pageUrl = URLEncoder.encode(pageUrl, "UTF-8");

            pageUrl = VeStr.Replace(pageUrl, dh, "=");
            pageUrl = VeStr.Replace(pageUrl, wh, "?");
            pageUrl = VeStr.Replace(pageUrl, yh, "&");
            pageUrl = VeStr.Replace(pageUrl, xg, "/");

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    StringBuffer url = new StringBuffer(pageUrl);
    if (pageUrl.indexOf("?") < 0)
        url.append("?");
    else
        url.append("&");

    ModelListForm form = null;
    try {
        form = (ModelListForm) FormBeanUtil.lookupActionForm((HttpServletRequest) pageContext.getRequest(),
                actionFormName);
        if (form == null)
            throw new Exception();
    } catch (Exception e) {
        Debug.logError("[JdonFramework]not found actionFormName value: " + actionFormName, module);
        throw new JspException(" not found " + actionFormName);
    }

    int start = form.getStart();
    int allCount = form.getAllCount();
    int count = form.getCount();
    url.append("count=").append(count);

    String nextPage = "";
    if ((allCount > (start + count)))
        nextPage = NEXTPAGE;

    pageContext.setAttribute(URLNAME, url.toString());
    pageContext.setAttribute(START, Integer.toString(start));
    pageContext.setAttribute(COUNT, Integer.toString(count));
    pageContext.setAttribute(ALLCOUNT, Integer.toString(allCount));
    pageContext.setAttribute(NEXTPAGE, nextPage);

    int currentPage = 1;
    if (count > 0) {
        currentPage = (start / count) + 1;
    }

    //??
    if ((currentPage == 1) && (nextPage.length() == 0)) {
        pageContext.setAttribute(DISP, "off"); //?
    } else
        pageContext.setAttribute(DISP, "on");

    // Evaluate the body of this tag
    return (EVAL_BODY_INCLUDE);

}