org.apache.jasper.JasperException Java Examples

The following examples show how to use org.apache.jasper.JasperException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JspServletWrapper.java    From packagedrone with Eclipse Public License 1.0 7 votes vote down vote up
JspServletWrapper(ServletConfig config, Options options, String jspUri,
                     boolean isErrorPage, JspRuntimeContext rctxt)
           throws JasperException {

this.isTagFile = false;
       this.config = config;
       this.options = options;
       this.jspUri = jspUri;
       this.jspProbeEmitter = (JspProbeEmitter)
           config.getServletContext().getAttribute(
               "org.glassfish.jsp.monitor.probeEmitter");

       ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
				 config.getServletContext(),
				 this, rctxt);
       // START PWC 6468930
       String jspFilePath = ctxt.getRealPath(jspUri);
       if (jspFilePath != null) {
           jspFile = new File(jspFilePath);
       }
       // END PWC 6468930
   }
 
Example #2
Source File: Parser.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Name ::= (Letter | '_' | ':') (Letter | Digit | '.' | '_' | '-' | ':')*
 */
private String parseName() throws JasperException {
    char ch = (char) reader.peekChar();
    if (Character.isLetter(ch) || ch == '_' || ch == ':') {
        StringBuilder buf = new StringBuilder();
        buf.append(ch);
        reader.nextChar();
        ch = (char) reader.peekChar();
        while (Character.isLetter(ch) || Character.isDigit(ch) || ch == '.'
                || ch == '_' || ch == '-' || ch == ':') {
            buf.append(ch);
            reader.nextChar();
            ch = (char) reader.peekChar();
        }
        return buf.toString();
    }
    return null;
}
 
Example #3
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(Node.InvokeAction n) throws JasperException {

    JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);

    String scope = n.getTextAttribute("scope");
    JspUtil.checkScope(scope, n, err);

    String var = n.getTextAttribute("var");
    String varReader = n.getTextAttribute("varReader");
    if (scope != null && var == null && varReader == null) {
        err.jspError(n, "jsp.error.missing_var_or_varReader");
    }
    if (var != null && varReader != null) {
        err.jspError(n, "jsp.error.var_and_varReader");
    }
}
 
Example #4
Source File: PageInfo.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public void setIsELIgnored(String value, Node n, ErrorDispatcher err,
		       boolean pagedir)
    throws JasperException {

if ("true".equalsIgnoreCase(value))
    isELIgnored = true;
else if ("false".equalsIgnoreCase(value))
    isELIgnored = false;
else {
    if (pagedir) 
	err.jspError(n, "jsp.error.page.invalid.iselignored");
    else 
	err.jspError(n, "jsp.error.tag.invalid.iselignored");
}

isELIgnoredValue = value;
   }
 
Example #5
Source File: TextOptimizer.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
public void visit(Node.TemplateText n) throws JasperException {

            if ((trim) && ! prePass && n.isAllSpace()) {
                n.setText(emptyText);
                return;
            }

            if (textNodeCount++ == 0) {
                firstTextNode = n;
                textBuffer = new StringBuilder(n.getText());
            } else {
                // Append text to text buffer
                textBuffer.append(n.getText());
                n.setText(emptyText);
            }
        }
 
Example #6
Source File: JspRuntimeLibrary.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public static Object getValueFromBeanInfoPropertyEditor(
                       Class<?> attrClass, String attrName, String attrValue,
                       Class<?> propertyEditorClass) 
    throws JasperException 
{
    try {
        PropertyEditor pe =
            (PropertyEditor)propertyEditorClass.newInstance();
        pe.setAsText(attrValue);
        return pe.getValue();
    } catch (Exception ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}
 
Example #7
Source File: Validator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(Node.InvokeAction n) throws JasperException {

    JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);

    String scope = n.getTextAttribute("scope");
    JspUtil.checkScope(scope, n, err);

    String var = n.getTextAttribute("var");
    String varReader = n.getTextAttribute("varReader");
    if (scope != null && var == null && varReader == null) {
        err.jspError(n, "jsp.error.missing_var_or_varReader");
    }
    if (var != null && varReader != null) {
        err.jspError(n, "jsp.error.var_and_varReader");
    }
}
 
Example #8
Source File: Validator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Node.PlugIn n) throws JasperException {
    JspUtil.checkAttributes("Plugin", n, plugInAttrs, err);

    throwErrorIfExpression(n, "type", "jsp:plugin");
    throwErrorIfExpression(n, "code", "jsp:plugin");
    throwErrorIfExpression(n, "codebase", "jsp:plugin");
    throwErrorIfExpression(n, "align", "jsp:plugin");
    throwErrorIfExpression(n, "archive", "jsp:plugin");
    throwErrorIfExpression(n, "hspace", "jsp:plugin");
    throwErrorIfExpression(n, "jreversion", "jsp:plugin");
    throwErrorIfExpression(n, "name", "jsp:plugin");
    throwErrorIfExpression(n, "vspace", "jsp:plugin");
    throwErrorIfExpression(n, "nspluginurl", "jsp:plugin");
    throwErrorIfExpression(n, "iepluginurl", "jsp:plugin");

    String type = n.getTextAttribute("type");
    if (type == null)
        err.jspError(n, "jsp.error.plugin.notype");
    if (!type.equals("bean") && !type.equals("applet"))
        err.jspError(n, "jsp.error.plugin.badtype");
    if (n.getTextAttribute("code") == null)
        err.jspError(n, "jsp.error.plugin.nocode");

    Node.JspAttribute width = getJspAttribute(null, "width", null,
            null, n.getAttributeValue("width"), n, null, false);
    n.setWidth(width);

    Node.JspAttribute height = getJspAttribute(null, "height", null,
            null, n.getAttributeValue("height"), n, null, false);
    n.setHeight(height);

    visitBody(n);
}
 
Example #9
Source File: ParserController.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private String getJspConfigPageEncoding(String absFileName)
throws JasperException {

    JspConfig jspConfig = ctxt.getOptions().getJspConfig();
    JspConfig.JspProperty jspProperty
        = jspConfig.findJspProperty(absFileName);
    return jspProperty.getPageEncoding();
}
 
Example #10
Source File: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static void handleSetProperty(Object bean, String prop,
                                     Object value)
    throws JasperException
{
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { value });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
 
Example #11
Source File: Parser.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private void parseUseBean(Node parent) throws JasperException {
    Attributes attrs = parseAttributes();
    reader.skipSpaces();

    Node useBeanNode = new Node.UseBean(attrs, start, parent);

    parseOptionalBody(useBeanNode, "jsp:useBean", TagInfo.BODY_CONTENT_JSP);
}
 
Example #12
Source File: ErrorDispatcher.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void doVisit(Node n) throws JasperException {
    if ((lineNum >= n.getBeginJavaLine())
            && (lineNum < n.getEndJavaLine())) {
        found = n;
    }
}
 
Example #13
Source File: Parser.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private void parseScriptlet(Node parent) throws JasperException {
    start = reader.mark();
    Mark stop = reader.skipUntil("%>");
    if (stop == null) {
        err.jspError(start, "jsp.error.unterminated", "&lt;%");
    }

    new Node.Scriptlet(parseScriptText(reader.getText(start, stop)), start,
            parent);
}
 
Example #14
Source File: Collector.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void visit(Node.PlugIn n) throws JasperException {
    if (n.getHeight() != null && n.getHeight().isExpression()) {
        scriptingElementSeen = true;
    }
    if (n.getWidth() != null && n.getWidth().isExpression()) {
        scriptingElementSeen = true;
    }
    visitBody(n);
}
 
Example #15
Source File: JspRuntimeLibrary.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static void handleSetProperty(Object bean, String prop,
                                     char value)
    throws JasperException
{
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { Character.valueOf(value) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
 
Example #16
Source File: BeanRepository.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public Class<?> getBeanType(String bean)
    throws JasperException {
    Class<?> clazz = null;
    try {
        clazz = loader.loadClass(beanTypes.get(bean));
    } catch (ClassNotFoundException ex) {
        throw new JasperException (ex);
    }
    return clazz;
}
 
Example #17
Source File: JspReader.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
boolean matchesETag(String tagName) throws JasperException {
    Mark mark = mark();

    if (!matches("</" + tagName))
        return false;
    skipSpaces();
    if (nextChar() == '>')
        return true;

    setCurrent(mark);
    return false;
}
 
Example #18
Source File: XMLEncodingDetector.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Autodetects the encoding of the XML document supplied by the given
 * input stream.
 *
 * Encoding autodetection is done according to the XML 1.0 specification,
 * Appendix F.1: Detection Without External Encoding Information.
 *
 * @return Two-element array, where the first element (of type
 * java.lang.String) contains the name of the (auto)detected encoding, and
 * the second element (of type java.lang.Boolean) specifies whether the 
 * encoding was specified using the 'encoding' attribute of an XML prolog
 * (TRUE) or autodetected (FALSE).
 */
public static Object[] getEncoding(String fname, JarFile jarFile,
                                   JspCompilationContext ctxt,
                                   ErrorDispatcher err)
    throws IOException, JasperException
{
    InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt,
                                                  err);
    XMLEncodingDetector detector = new XMLEncodingDetector();
    Object[] ret = detector.getEncoding(inStream, err);
    inStream.close();

    return ret;
}
 
Example #19
Source File: SmapUtil.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private void evaluateNodes(
    Node.Nodes nodes,
    SmapStratum s,
    boolean breakAtLF) {
    try {
        nodes.visit(new SmapGenVisitor(s, breakAtLF, classInfos));
    } catch (JasperException ex) {
    }
}
 
Example #20
Source File: PageDataImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Node.TemplateText n) throws JasperException {
        /*
         * If the template text came from a JSP page written in JSP syntax,
         * create a jsp:text element for it (JSP 5.3.2).
         */
        appendText(n.getText(), !n.getRoot().isXmlSyntax());
    }
 
Example #21
Source File: Generator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Generate code to create a map for the alias variables
 * @return the name of the map
 */
private String generateAliasMap(Node.CustomTag n, String tagHandlerVar)
    throws JasperException {

    TagVariableInfo[] tagVars = n.getTagVariableInfos();
    String aliasMapVar = null;

    boolean aliasSeen = false;
    for (int i = 0; i < tagVars.length; i++) {

        String nameFrom = tagVars[i].getNameFromAttribute();
        if (nameFrom != null) {
            String aliasedName = n.getAttributeValue(nameFrom);
            if (aliasedName == null)
                continue;

            if (!aliasSeen) {
                out.printin("java.util.HashMap ");
                aliasMapVar = tagHandlerVar + "_aliasMap";
                out.print(aliasMapVar);
                out.println(" = new java.util.HashMap();");
                aliasSeen = true;
            }
            out.printin(aliasMapVar);
            out.print(".put(");
            out.print(quote(tagVars[i].getNameGiven()));
            out.print(", ");
            out.print(quote(aliasedName));
            out.println(");");
        }
    }
    return aliasMapVar;
}
 
Example #22
Source File: JspRuntimeLibrary.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static void introspect(Object bean, ServletRequest request)
                              throws JasperException
{
    Enumeration<String> e = request.getParameterNames();
    while ( e.hasMoreElements() ) {
        String name  = e.nextElement();
        String value = request.getParameter(name);
        introspecthelper(bean, name, value, request, name, true);
    }
}
 
Example #23
Source File: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public static void handleSetProperty(Object bean, String prop,
                                     byte value)
    throws JasperException
{
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { Byte.valueOf(value) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }        
}
 
Example #24
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public void visit(Node.TaglibDirective n) throws JasperException {
           JspUtil.checkAttributes("Taglib directive", n,
                                   taglibDirectiveAttrs, err);
    // Either 'uri' or 'tagdir' attribute must be specified
    String uri = n.getAttributeValue("uri");
    String tagdir = n.getAttributeValue("tagdir");
    if (uri == null && tagdir == null) {
	err.jspError(n, "jsp.error.taglibDirective.missing.location");
    }
    if (uri != null && tagdir != null) {
	err.jspError(n, "jsp.error.taglibDirective.both_uri_and_tagdir");
    }
}
 
Example #25
Source File: Collector.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void visit(Node.ParamAction n) throws JasperException {
    if (n.getValue().isExpression()) {
        scriptingElementSeen = true;
    }
    paramActionSeen = true;
}
 
Example #26
Source File: Dumper.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void visit(Node.ELExpression n) throws JasperException {
    printString( "${" + n.getText() + "}" );
}
 
Example #27
Source File: Generator.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private void generateCustomDoTag(Node.CustomTag n,
        TagHandlerInfo handlerInfo, String tagHandlerVar)
        throws JasperException {

    Class<?> tagHandlerClass =
        handlerInfo.getTagHandlerClass();

    n.setBeginJavaLine(out.getJavaLine());
    out.printin("//  ");
    out.println(n.getQName());

    // Declare AT_BEGIN scripting variables
    declareScriptingVars(n, VariableInfo.AT_BEGIN);
    saveScriptingVars(n, VariableInfo.AT_BEGIN);

    String tagHandlerClassName = tagHandlerClass.getCanonicalName();
    writeNewInstance(tagHandlerVar, tagHandlerClassName);

    generateSetters(n, tagHandlerVar, handlerInfo, true);

    // JspIdConsumer (after context has been set)
    if (n.implementsJspIdConsumer()) {
        out.printin(tagHandlerVar);
        out.print(".setJspId(\"");
        out.print(createJspId());
        out.println("\");");
    }

    // Set the body
    if (findJspBody(n) == null) {
        /*
         * Encapsulate body of custom tag invocation in JspFragment and
         * pass it to tag handler's setJspBody(), unless tag body is
         * empty
         */
        if (!n.hasEmptyBody()) {
            out.printin(tagHandlerVar);
            out.print(".setJspBody(");
            generateJspFragment(n, tagHandlerVar);
            out.println(");");
        }
    } else {
        /*
         * Body of tag is the body of the <jsp:body> element. The visit
         * method for that element is going to encapsulate that
         * element's body in a JspFragment and pass it to the tag
         * handler's setJspBody()
         */
        String tmpTagHandlerVar = simpleTagHandlerVar;
        simpleTagHandlerVar = tagHandlerVar;
        boolean tmpIsSimpleTagHandler = isSimpleTagHandler;
        isSimpleTagHandler = true;
        visitBody(n);
        simpleTagHandlerVar = tmpTagHandlerVar;
        isSimpleTagHandler = tmpIsSimpleTagHandler;
    }

    out.printin(tagHandlerVar);
    out.println(".doTag();");

    restoreScriptingVars(n, VariableInfo.AT_BEGIN);

    // Synchronize AT_BEGIN scripting variables
    syncScriptingVars(n, VariableInfo.AT_BEGIN);

    // Declare and synchronize AT_END scripting variables
    declareScriptingVars(n, VariableInfo.AT_END);
    syncScriptingVars(n, VariableInfo.AT_END);

    // Resource injection
    writeDestroyInstance(tagHandlerVar);

    n.setEndJavaLine(out.getJavaLine());
}
 
Example #28
Source File: SmapUtil.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void visit(Node.JspText n) throws JasperException {
    doSmap(n);
    visitBody(n);
}
 
Example #29
Source File: Node.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
public void visit(DoBodyAction n) throws JasperException {
    doVisit(n);
    visitBody(n);
}
 
Example #30
Source File: Generator.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(Node.NamedAttribute n) throws JasperException {
    // Don't visit body of this tag - we already did earlier.
}