javax.servlet.SingleThreadModel#org.apache.jasper.compiler.Localizer源码实例Demo

下面列出了javax.servlet.SingleThreadModel#org.apache.jasper.compiler.Localizer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tomcat8-Source-Read   文件: JspServlet.java
private void handleMissingResource(HttpServletRequest request,
        HttpServletResponse response, String jspUri)
        throws ServletException, IOException {

    String includeRequestUri =
        (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);

    if (includeRequestUri != null) {
        // This file was included. Throw an exception as
        // a response.sendError() will be ignored
        String msg =
            Localizer.getMessage("jsp.error.file.not.found",jspUri);
        // Strictly, filtering this is an application
        // responsibility but just in case...
        throw new ServletException(Escape.htmlElementContent(msg));
    } else {
        try {
            response.sendError(HttpServletResponse.SC_NOT_FOUND,
                    request.getRequestURI());
        } catch (IllegalStateException ise) {
            log.error(Localizer.getMessage("jsp.error.file.not.found",
                    jspUri));
        }
    }
    return;
}
 
public Class<?> load() throws JasperException {
    try {
        getJspLoader();

        String name = getFQCN();
        servletClass = jspLoader.loadClass(name);
    } catch (ClassNotFoundException cex) {
        throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
                cex);
    } catch (Exception ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
                ex);
    }
    removed = false;
    return servletClass;
}
 
protected void createOutputDir() {
    String path = null;
    if (isTagFile()) {
        String tagName = tagInfo.getTagClassName();
        path = tagName.replace('.', File.separatorChar);
        path = path.substring(0, path.lastIndexOf(File.separatorChar));
    } else {
        path = getServletPackageName().replace('.',File.separatorChar);
    }

    // Append servlet or tag handler path to scratch dir
    try {
        File base = options.getScratchDir();
        baseUrl = base.toURI().toURL();
        outputDir = base.getAbsolutePath() + File.separator + path +
                File.separator;
        if (!makeOutputDir()) {
            throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"));
        }
    } catch (MalformedURLException e) {
        throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"), e);
    }
}
 
源代码4 项目: Tomcat8-Source-Read   文件: JspC.java
protected void completeWebXml() {
    if (mapout != null) {
        try {
            servletout.writeTo(mapout);
            mappingout.writeTo(mapout);
            if (webxmlLevel >= ALL_WEBXML) {
                mapout.write(Localizer.getMessage("jspc.webxml.footer"));
            } else if (webxmlLevel >= FRG_WEBXML) {
                    mapout.write(Localizer.getMessage("jspc.webfrg.footer"));
            } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
                mapout.write(Localizer.getMessage("jspc.webinc.footer"));
            }
            mapout.close();
        } catch (IOException ioe) {
            // nothing to do if it fails since we are done with it
        }
    }
}
 
源代码5 项目: Tomcat8-Source-Read   文件: JspContextWrapper.java
@Override
public void setAttribute(String name, Object value, int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (scope == PAGE_SCOPE) {
        if (value != null) {
            pageAttributes.put(name, value);
        } else {
            removeAttribute(name, PAGE_SCOPE);
        }
    } else {
        rootJspCtxt.setAttribute(name, value, scope);
    }
}
 
源代码6 项目: Tomcat8-Source-Read   文件: JspContextWrapper.java
@Override
public Object findAttribute(String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    Object o = pageAttributes.get(name);
    if (o == null) {
        o = rootJspCtxt.getAttribute(name, REQUEST_SCOPE);
        if (o == null) {
            if (getSession() != null) {
                o = rootJspCtxt.getAttribute(name, SESSION_SCOPE);
            }
            if (o == null) {
                o = rootJspCtxt.getAttribute(name, APPLICATION_SCOPE);
            }
        }
    }

    return o;
}
 
源代码7 项目: Tomcat8-Source-Read   文件: JspRuntimeLibrary.java
public static Object handleGetProperty(Object o, String prop)
throws JasperException {
    if (o == null) {
        throw new JasperException(
                Localizer.getMessage("jsp.error.beans.nullbean"));
    }
    Object value = null;
    try {
        Method method = getReadMethod(o.getClass(), prop);
        value = method.invoke(o, (Object[]) null);
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException (ex);
    }
    return value;
}
 
源代码8 项目: Tomcat7.0.67   文件: PageContextImpl.java
@Override
public void setAttribute(final String name, final Object attribute) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, attribute);
                return null;
            }
        });
    } else {
        doSetAttribute(name, attribute);
    }
}
 
源代码9 项目: Tomcat7.0.67   文件: ASCIIReader.java
/**
 * Read characters into a portion of an array.  This method will block
 * until some input is available, an I/O error occurs, or the end of the
 * stream is reached.
 *
 * @param      ch     Destination buffer
 * @param      offset Offset at which to start storing characters
 * @param      length Maximum number of characters to read
 *
 * @return     The number of characters read, or -1 if the end of the
 *             stream has been reached
 *
 * @exception  IOException  If an I/O error occurs
 */
@Override
public int read(char ch[], int offset, int length) throws IOException {
    if (length > fBuffer.length) {
        length = fBuffer.length;
    }
    int count = fInputStream.read(fBuffer, 0, length);
    for (int i = 0; i < count; i++) {
        int b0 = (0xff & fBuffer[i]); // Convert to unsigned
        if (b0 > 0x80) {
            throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
                                                       Integer.toString(b0)));
        }
        ch[offset + i] = (char)b0;
    }
    return count;
}
 
源代码10 项目: Tomcat8-Source-Read   文件: JspRuntimeLibrary.java
public static Object getValueFromPropertyEditorManager(
                 Class<?> attrClass, String attrName, String attrValue)
    throws JasperException
{
    try {
        PropertyEditor propEditor =
            PropertyEditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}
 
源代码11 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public Object getAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name);
            }
        });
    } else {
        return doGetAttribute(name);
    }

}
 
源代码12 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public Object getAttribute(final String name, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                return doGetAttribute(name, scope);
            }
        });
    } else {
        return doGetAttribute(name, scope);
    }

}
 
源代码13 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
private Object doGetAttribute(String name, int scope) {
    switch (scope) {
    case PAGE_SCOPE:
        return attributes.get(name);

    case REQUEST_SCOPE:
        return request.getAttribute(name);

    case SESSION_SCOPE:
        if (session == null) {
            throw new IllegalStateException(Localizer
                    .getMessage("jsp.error.page.noSession"));
        }
        return session.getAttribute(name);

    case APPLICATION_SCOPE:
        return context.getAttribute(name);

    default:
        throw new IllegalArgumentException("Invalid scope");
    }
}
 
源代码14 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public void setAttribute(final String name, final Object attribute) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, attribute);
                return null;
            }
        });
    } else {
        doSetAttribute(name, attribute);
    }
}
 
源代码15 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public void setAttribute(final String name, final Object o, final int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doSetAttribute(name, o, scope);
                return null;
            }
        });
    } else {
        doSetAttribute(name, o, scope);
    }

}
 
源代码16 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
private void doRemoveAttribute(String name, int scope) {
    switch (scope) {
    case PAGE_SCOPE:
        attributes.remove(name);
        break;

    case REQUEST_SCOPE:
        request.removeAttribute(name);
        break;

    case SESSION_SCOPE:
        if (session == null) {
            throw new IllegalStateException(Localizer
                    .getMessage("jsp.error.page.noSession"));
        }
        session.removeAttribute(name);
        break;

    case APPLICATION_SCOPE:
        context.removeAttribute(name);
        break;

    default:
        throw new IllegalArgumentException("Invalid scope");
    }
}
 
源代码17 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public int getAttributesScope(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (AccessController
                .doPrivileged(new PrivilegedAction<Integer>() {
                    @Override
                    public Integer run() {
                        return Integer.valueOf(doGetAttributeScope(name));
                    }
                })).intValue();
    } else {
        return doGetAttributeScope(name);
    }
}
 
源代码18 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public Object findAttribute(final String name) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                if (name == null) {
                    throw new NullPointerException(Localizer
                            .getMessage("jsp.error.attribute.null_name"));
                }

                return doFindAttribute(name);
            }
        });
    } else {
        if (name == null) {
            throw new NullPointerException(Localizer
                    .getMessage("jsp.error.attribute.null_name"));
        }

        return doFindAttribute(name);
    }
}
 
源代码19 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
private Enumeration<String> doGetAttributeNamesInScope(int scope) {
    switch (scope) {
    case PAGE_SCOPE:
        return Collections.enumeration(attributes.keySet());

    case REQUEST_SCOPE:
        return request.getAttributeNames();

    case SESSION_SCOPE:
        if (session == null) {
            throw new IllegalStateException(Localizer
                    .getMessage("jsp.error.page.noSession"));
        }
        return session.getAttributeNames();

    case APPLICATION_SCOPE:
        return context.getAttributeNames();

    default:
        throw new IllegalArgumentException("Invalid scope");
    }
}
 
源代码20 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public void removeAttribute(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                doRemoveAttribute(name);
                return null;
            }
        });
    } else {
        doRemoveAttribute(name);
    }
}
 
源代码21 项目: Tomcat8-Source-Read   文件: ASCIIReader.java
/**
 * Read characters into a portion of an array.  This method will block
 * until some input is available, an I/O error occurs, or the end of the
 * stream is reached.
 *
 * @param      ch     Destination buffer
 * @param      offset Offset at which to start storing characters
 * @param      length Maximum number of characters to read
 *
 * @return     The number of characters read, or -1 if the end of the
 *             stream has been reached
 *
 * @exception  IOException  If an I/O error occurs
 */
@Override
public int read(char ch[], int offset, int length) throws IOException {
    if (length > fBuffer.length) {
        length = fBuffer.length;
    }
    int count = fInputStream.read(fBuffer, 0, length);
    for (int i = 0; i < count; i++) {
        int b0 = (0xff & fBuffer[i]); // Convert to unsigned
        if (b0 > 0x80) {
            throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
                                                       Integer.toString(b0)));
        }
        ch[offset + i] = (char)b0;
    }
    return count;
}
 
源代码22 项目: Tomcat7.0.67   文件: JspServlet.java
private void handleMissingResource(HttpServletRequest request,
        HttpServletResponse response, String jspUri)
        throws ServletException, IOException {

    String includeRequestUri =
        (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);

    if (includeRequestUri != null) {
        // This file was included. Throw an exception as
        // a response.sendError() will be ignored
        String msg =
            Localizer.getMessage("jsp.error.file.not.found",jspUri);
        // Strictly, filtering this is an application
        // responsibility but just in case...
        throw new ServletException(SecurityUtil.filter(msg));
    } else {
        try {
            response.sendError(HttpServletResponse.SC_NOT_FOUND,
                    request.getRequestURI());
        } catch (IllegalStateException ise) {
            log.error(Localizer.getMessage("jsp.error.file.not.found",
                    jspUri));
        }
    }
    return;
}
 
源代码23 项目: Tomcat7.0.67   文件: PageContextImpl.java
private void doRemoveAttribute(String name, int scope) {
    switch (scope) {
    case PAGE_SCOPE:
        attributes.remove(name);
        break;

    case REQUEST_SCOPE:
        request.removeAttribute(name);
        break;

    case SESSION_SCOPE:
        if (session == null) {
            throw new IllegalStateException(Localizer
                    .getMessage("jsp.error.page.noSession"));
        }
        session.removeAttribute(name);
        break;

    case APPLICATION_SCOPE:
        context.removeAttribute(name);
        break;

    default:
        throw new IllegalArgumentException("Invalid scope");
    }
}
 
源代码24 项目: Tomcat7.0.67   文件: JspCompilationContext.java
public Class<?> load() throws JasperException {
    try {
        getJspLoader();

        String name = getFQCN();
        servletClass = jspLoader.loadClass(name);
    } catch (ClassNotFoundException cex) {
        throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
                                  cex);
    } catch (Exception ex) {
        throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
                                  ex);
    }
    removed = 0;
    return servletClass;
}
 
源代码25 项目: Tomcat7.0.67   文件: JspCompilationContext.java
protected void createOutputDir() {
    String path = null;
    if (isTagFile()) {
        String tagName = tagInfo.getTagClassName();
        path = tagName.replace('.', File.separatorChar);
        path = path.substring(0, path.lastIndexOf(File.separatorChar));
    } else {
        path = getServletPackageName().replace('.',File.separatorChar);
    }

        // Append servlet or tag handler path to scratch dir
        try {
            File base = options.getScratchDir();
            baseUrl = base.toURI().toURL();
            outputDir = base.getAbsolutePath() + File.separator + path +
                File.separator;
            if (!makeOutputDir()) {
                throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"));
            }
        } catch (MalformedURLException e) {
            throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"), e);
        }
}
 
源代码26 项目: Tomcat7.0.67   文件: JspC.java
protected void initWebXml() {
    try {
        if (webxmlLevel >= INC_WEBXML) {
            mapout = openWebxmlWriter(new File(webxmlFile));
            servletout = new CharArrayWriter();
            mappingout = new CharArrayWriter();
        } else {
            mapout = null;
            servletout = null;
            mappingout = null;
        }
        if (webxmlLevel >= ALL_WEBXML) {
            mapout.write(Localizer.getMessage("jspc.webxml.header"));
            mapout.flush();
        } else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
            mapout.write(Localizer.getMessage("jspc.webinc.header"));
            mapout.flush();
        }
    } catch (IOException ioe) {
        mapout = null;
        servletout = null;
        mappingout = null;
    }
}
 
源代码27 项目: Tomcat7.0.67   文件: JspC.java
protected void completeWebXml() {
    if (mapout != null) {
        try {
            servletout.writeTo(mapout);
            mappingout.writeTo(mapout);
            if (webxmlLevel >= ALL_WEBXML) {
                mapout.write(Localizer.getMessage("jspc.webxml.footer"));
            } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
                mapout.write(Localizer.getMessage("jspc.webinc.footer"));
            }
            mapout.close();
        } catch (IOException ioe) {
            // noting to do if it fails since we are done with it
        }
    }
}
 
源代码28 项目: Tomcat7.0.67   文件: JspContextWrapper.java
@Override
public void setAttribute(String name, Object value, int scope) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (scope == PAGE_SCOPE) {
        if (value != null) {
            pageAttributes.put(name, value);
        } else {
            removeAttribute(name, PAGE_SCOPE);
        }
    } else {
        rootJspCtxt.setAttribute(name, value, scope);
    }
}
 
源代码29 项目: Tomcat7.0.67   文件: PageContextImpl.java
@Override
public int getAttributesScope(final String name) {

    if (name == null) {
        throw new NullPointerException(Localizer
                .getMessage("jsp.error.attribute.null_name"));
    }

    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (AccessController
                .doPrivileged(new PrivilegedAction<Integer>() {
                    @Override
                    public Integer run() {
                        return Integer.valueOf(doGetAttributeScope(name));
                    }
                })).intValue();
    } else {
        return doGetAttributeScope(name);
    }
}
 
源代码30 项目: Tomcat7.0.67   文件: JspRuntimeLibrary.java
public static Object handleGetProperty(Object o, String prop)
throws JasperException {
    if (o == null) {
        throw new JasperException(
                Localizer.getMessage("jsp.error.beans.nullbean"));
    }
    Object value = null;
    try {
        Method method = getReadMethod(o.getClass(), prop);
        value = method.invoke(o, (Object[]) null);
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException (ex);
    }
    return value;
}