Package javax.servlet.jsp

Examples of javax.servlet.jsp.JspTagException


public class HelloTag extends TagSupport {
   public int doStartTag() throws JspException {
      try {
          pageContext.getOut().print("Hello");
      } catch (Exception e) {
          throw new JspTagException(e.getMessage());
      }
      return SKIP_BODY;
   }
View Full Code Here


    // Private conversion methods to handle the various types we support

    // catch-all method whose invocation currently signals a 'matching error'
    protected static ForEachIterator toForEachIterator(Object o)
      throws JspTagException {
  throw new JspTagException("FOREACH_BAD_ITEMS");
    }
View Full Code Here

                                try {
              m.invoke(target,
                   new Object[] {
                                         convertToExpectedType(result, m.getParameterTypes()[0])});
                                } catch (javax.el.ELException ex) {
                                    throw new JspTagException(ex);
                                }
          } else {
        m.invoke(target, new Object[] { null });
          }
          succeeded = true;
      }
        }
        if (!succeeded) {
      throw new JspTagException(
          Resources.getMessage("SET_INVALID_PROPERTY",
        property));
        }
    } catch (IllegalAccessException ex) {
        throw new JspException(ex);
    } catch (IntrospectionException ex) {
        throw new JspException(ex);
    } catch (InvocationTargetException ex) {
        throw new JspException(ex);
    }
      }
  } else {
      // should't ever occur because of validation in TLV and setters
      throw new JspTagException();
  }

  return EVAL_PAGE;
    }
View Full Code Here

  // redirect!
  try {
      response.sendRedirect(result);
  } catch (java.io.IOException ex) {
      throw new JspTagException(ex.toString(), ex);
  }

  return SKIP_PAGE;
    }
View Full Code Here

        if (items instanceof ValueExpression) {
            deferredExpression = (ValueExpression) items;
            items = deferredExpression.getValue(pageContext.getELContext());
        }
        if (!(items instanceof String)) {
            throw new JspTagException(
                Resources.getMessage("FORTOKENS_BAD_ITEMS"));
        }
        st = new StringTokenizer((String)items, delims);
    }
View Full Code Here

    public int doEndTag() throws JspException {
  SQLExecutionTag parent = (SQLExecutionTag)
      findAncestorWithClass(this, SQLExecutionTag.class);
  if (parent == null) {
      throw new JspTagException(
                Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
  }

        if (value != null) {
            convertValue();
View Full Code Here

    // determines what kind of import and variable exposure to perform
    public int doStartTag() throws JspException {
  // Sanity check
  if (context != null
          && (!context.startsWith("/") || !url.startsWith("/"))) {
      throw new JspTagException(
    Resources.getMessage("IMPORT_BAD_RELATIVE"));
  }

  // reset parameter-related state
  urlWithParams = null;
  params = new ParamSupport.ParamManager();

  // check the URL
  if (url == null || url.equals(""))
      throw new NullAttributeException("import", "url");

  // Record whether our URL is absolute or relative
  isAbsoluteUrl = isAbsoluteUrl();

  try {
      // If we need to expose a Reader, we've got to do it right away
      if  (varReader != null) {
          r = acquireReader();
          pageContext.setAttribute(varReader, r);
      }
  } catch (IOException ex) {
      throw new JspTagException(ex.toString(), ex);
  }

  return EVAL_BODY_INCLUDE;
    }
View Full Code Here

          else
              pageContext.getOut().print(acquireString());
      }
      return EVAL_PAGE;
        } catch (IOException ex) {
      throw new JspTagException(ex.toString(), ex);
        }
    }
View Full Code Here

            // handle relative URLs ourselves
           
            // URL is relative, so we must be an HTTP request
            if (!(pageContext.getRequest() instanceof HttpServletRequest
                  && pageContext.getResponse() instanceof HttpServletResponse))
                throw new JspTagException(
                                          Resources.getMessage("IMPORT_REL_WITHOUT_HTTP"));
           
            // retrieve an appropriate ServletContext
            ServletContext c = null;
            String targetUrl = targetUrl();
            if (context != null)
                c = pageContext.getServletContext().getContext(context);
            else {
                c = pageContext.getServletContext();
               
                // normalize the URL if we have an HttpServletRequest
                if (!targetUrl.startsWith("/")) {
                    String sp = ((HttpServletRequest)
                                 pageContext.getRequest()).getServletPath();
                    targetUrl = sp.substring(0, sp.lastIndexOf('/'))
                        + '/' + targetUrl;
                }
            }
           
            if (c == null) {
                throw new JspTagException(
                                          Resources.getMessage(
                                                               "IMPORT_REL_WITHOUT_DISPATCHER", context, targetUrl));
            }
           
            // from this context, get a dispatcher
            RequestDispatcher rd =
                c.getRequestDispatcher(stripSession(targetUrl));
            if (rd == null)
                throw new JspTagException(stripSession(targetUrl));
           
            // include the resource, using our custom wrapper
            ImportResponseWrapper irw =
                new ImportResponseWrapper(pageContext);
           
            // spec mandates specific error handling form include()
            try {
                rd.include(pageContext.getRequest(), irw);
            } catch (IOException ex) {
                throw new JspException(ex);
            } catch (RuntimeException ex) {
                throw new JspException(ex);
            } catch (ServletException ex) {
                Throwable rc = ex.getRootCause();
                if (rc == null)
                    throw new JspException(ex);
                else
                    throw new JspException(rc);
            }
           
            // disallow inappropriate response codes per JSTL spec
            if (irw.getStatus() < 200 || irw.getStatus() > 299) {
                throw new JspTagException(irw.getStatus() + " " +
                                          stripSession(targetUrl));
            }
           
            // recover the response String from our wrapper
            return irw.getString();
View Full Code Here

                // check response code for HTTP URLs before returning, per spec,
                // before returning
                if (uc instanceof HttpURLConnection) {
                    int status = ((HttpURLConnection) uc).getResponseCode();
                    if (status < 200 || status > 299)
                        throw new JspTagException(status + " " + target);
                }
                return r;
            } catch (IOException ex) {
                throw new JspException(
                                       Resources.getMessage("IMPORT_ABS_ERROR", target, ex), ex);
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.JspTagException

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.