Package javax.servlet.jsp

Examples of javax.servlet.jsp.JspException


            // look for outer iterate tag
            IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, IterateTag.class);
            if (iterateTag == null) {
                // This tag should only be nested in an iterate tag
                // If it's not, throw exception
                JspException e = new JspException(messages.getMessage("indexed.noEnclosingIterate"));
                TagUtils.getInstance().saveException(pageContext, e);
                throw e;
            }

            // calculate index, and add as a parameter
            if (params == null) {
                params = new HashMap(); // create new HashMap if no other params
            }
            if (indexId != null) {
                params.put(indexId, Integer.toString(iterateTag.getIndex()));
            } else {
                params.put("index", Integer.toString(iterateTag.getIndex()));
            }

        }

        // get the pager object
        Pager pager = (Pager) TagUtils.getInstance().lookup(pageContext, pagerName, pagerProperty, scope);
        if (pager != null) {
            if (params == null) {
                params = new HashMap(); // create new HashMap if no other params
            }
            String name =  pager.getModel().getId() + "." + pager.getModel().getColumnName(columnIndex);

            // NOTE - These are now stored in the session anyway - BPS
            params.put("pageSize", String.valueOf(pager.getPageSize()));
            params.put("startRow", String.valueOf(pager.getStartRow()));
            params.put("sortName", name);
            params.put("sortReverse", name.equals(pager.getModel().getId() + "." + pager.getSortName()) ? String.valueOf(!pager.getSortReverse()) : "false");
        }
       
        if (subForm != null)
            params.put("subForm", subForm);

        if(attributesName != null) {
            StringTokenizer t = new StringTokenizer(attributesProperties, ",");
            while (t.hasMoreTokens()) {
                String attr = t.nextToken();
                try {
                    params.put(attr, TagUtils.getInstance().lookup(pageContext, attributesName, attr, scope).toString());
                } catch (Exception e) {
                }
            }
        }
        String newPage = page;

        FormTag formTag = (FormTag)CoreUtil.getParentTagOfClass(FormTag.class, this);

        if(forward == null && newPage == null && action == null && href == null &&
                        formTag != null) {
            newPage = formTag.getAction();
        }
       
        String url = null;
        try {
            url = TagUtils.getInstance().computeURLWithCharEncoding(pageContext, forward, href, newPage, action, module, params,
                anchor, false, useLocalEncoding);
        } catch (MalformedURLException e) {
            TagUtils.getInstance().saveException(pageContext, e);
            throw new JspException(messages.getMessage("rewrite.url", e.toString()));
        }
        return (url);

    }
View Full Code Here


    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    FormsSupport support = FormsSupport.getInstance(request);

    FormTag formTag = (FormTag)findAncestorWithClass(this, FormTag.class);
    if (formTag == null) {
      throw new JspException("Cannot get enclosing form tag");
    }
    String action = formTag.getAction();
     
    FormData formData = null;
    try {
      formData = support.getFormData(request, action, false);
    } catch (Exception e) {
      throw new JspException("Cannot get form data for action '" + action + "'!");
    }
    if (formData instanceof FlushableForm) {
      FlushableForm values = (FlushableForm)formData;
      FormResult result = support.getFormResult(request, action);
      if (result != null) {
        try {
          Iterator inputs = result.getFormInputResults();
          while (inputs.hasNext()) {
            FormInputResult inputResult = (FormInputResult)inputs.next();
            FormInput input = inputResult.getFormInput();
            Object value = inputResult.format(request);
            if (input.isArray()) {
              values._setInputs(input.getName(), (String[])value);
            } else {
              values._setInput(input.getName(), (String)value);
            }
          }
        } catch (Exception e) {
          throw new JspException(e);
        }
      } else {
        Form form = support.getForm(request, action);
        if (form == null) {
          throw new JspException("Cannot find form for action '" + action + "'!");
        }
        try {
          Iterator inputs = form.getFormInputs();
          while (inputs.hasNext()) {
            FormInput input = (FormInput)inputs.next();
            Object value = input.format(request, formData);
            if (input.isArray()) {
              values._setInputs(input.getName(), (String[])value);
            } else {
              values._setInput(input.getName(), (String)value);
            }
          }
        } catch (Exception e) {
          throw new JspException(e);
        }
      }
    }
    return EVAL_PAGE;
  }
View Full Code Here

  private void render(StringBuffer s) throws JspException {
    if (s.length() > 0) {
      try {
        pageContext.getOut().print(s.toString());
      } catch (IOException e) {
        throw new JspException(e);
      }
    }
  }
View Full Code Here

   */
  public final int doStartTag() throws JspException {
    try {
      init();
    } catch (Exception e) {
      throw new JspException(e);
    }
    StringBuffer s = new StringBuffer();
    if (name != null) {
      s.append("<");
      s.append(name);
      try {
        appendAttributes(s);
      } catch (Exception e) {
        throw new JspException(e);
      }
      s.append(body ? ">" : "/>");
    }
    if (body) {
      try {
        String content = getBodyContent();
        if (content != null) {
          s.append(content);
          render(s);
          return SKIP_BODY;
        }
      } catch (Exception e) {
        throw new JspException(e);
      }
      render(s);
      return EVAL_BODY_INCLUDE;
    } else {
      render(s);
View Full Code Here

    public int doStartTag() throws JspException {
        if (Config.getInstance().isEnabled()) {
            int ownership = StringUtils.findIgnoreCase(owner, NavigationManager.OWNERSHIP_DESC);

            if (ownership < 0) {
                throw new JspException("The ownership must be included in " +
                    Arrays.asList(NavigationManager.OWNERSHIP_DESC));
            }

            NavigationContextFactory.getInstance().addOwnership(key, ownership);
        }
View Full Code Here

            if ((owner != null) && (owner.length() > 0)) {
                ownership = StringUtils.findIgnoreCase(owner, NavigationManager.OWNERSHIP_DESC);

                if (ownership < 0) {
                    throw new JspException("The ownership must be included in " +
                        Arrays.asList(NavigationManager.OWNERSHIP_DESC).toString());
                }
            } else {
                ownership = Config.getInstance().getDefaultOwnership();
            }
View Full Code Here

        buffer1.append("</table>\n");

        try {
            pageContext.getOut().print(buffer1.toString());
        } catch (IOException ioe) {
            throw new JspException("Unable to print out the status", ioe);
        }

        return SKIP_BODY;
    }
View Full Code Here

                        public void invoke(Writer out) throws JspException, IOException {
                            try {
                                body.render(out == null ? pageContext.getOut() : out);
                            }
                            catch(TemplateException e) {
                                throw new JspException(e);
                            }
                        }
                    });
                    pageContext.pushTopTag(tag);
                    try {
View Full Code Here

  /**
   * Throw an exception on attempt to set key. This tag supports "escape" only!
   */
  public void setKey(String key) throws JspException {
    throw new JspException("You may not set key for the escape handler tag!");
  }
View Full Code Here

 
  /**
   * @see #setKey
   */
  public void setKeyCode(String keyCode) throws JspException {
    throw new JspException("You may not set keyCode for the escape handler tag!");
  }
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.JspException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.