org.apache.jasper.Constants Java Examples

The following examples show how to use org.apache.jasper.Constants. 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: TagHandlerPool.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
protected void init(ServletConfig config) {
    int maxSize = -1;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        try {
            maxSize = Integer.parseInt(maxSizeS);
        } catch (Exception ex) {
            maxSize = -1;
        }
    }
    if (maxSize < 0) {
        maxSize = Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
Example #2
Source File: ELFunctionMapper.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Convert a binary class name into a canonical one that can be used
 * when generating Java source code.
 *
 * @param className Binary class name
 * @return          Canonical equivalent
 */
private String getCanonicalName(String className) throws JasperException {
    Class<?> clazz;

    ClassLoader tccl;
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
        tccl = AccessController.doPrivileged(pa);
    } else {
        tccl = Thread.currentThread().getContextClassLoader();
    }

    try {
        clazz = Class.forName(className, false, tccl);
    } catch (ClassNotFoundException e) {
        throw new JasperException(e);
    }
    return clazz.getCanonicalName();
}
 
Example #3
Source File: PerThreadTagHandlerPool.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
protected void init(ServletConfig config) {
    maxSize = Constants.MAX_POOL_SIZE;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        maxSize = Integer.parseInt(maxSizeS);
        if (maxSize < 0) {
            maxSize = Constants.MAX_POOL_SIZE;
        }
    }

    perThread = new ThreadLocal<PerThreadData>() {
        @Override
        protected PerThreadData initialValue() {
            PerThreadData ptd = new PerThreadData();
            ptd.handlers = new Tag[maxSize];
            ptd.current = -1;
            perThreadDataVector.addElement(ptd);
            return ptd;
        }
    };
}
 
Example #4
Source File: Generator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private void writeNewInstance(String tagHandlerVar, String tagHandlerClassName) {
    out.printin(tagHandlerClassName);
    out.print(" ");
    out.print(tagHandlerVar);
    out.print(" = ");
    if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
        out.print("(");
        out.print(tagHandlerClassName);
        out.print(")");
        out.print("_jsp_getInstanceManager().newInstance(\"");
        out.print(tagHandlerClassName);
        out.println("\", this.getClass().getClassLoader());");
    } else {
        out.print("new ");
        out.print(tagHandlerClassName);
        out.println("();");
        out.printin("_jsp_getInstanceManager().newInstance(");
        out.print(tagHandlerVar);
        out.println(");");
    }
}
 
Example #5
Source File: PageInfo.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
PageInfo(BeanRepository beanRepository, String jspFile, boolean isTagFile) {
    this.isTagFile = isTagFile;
    this.jspFile = jspFile;
    this.beanRepository = beanRepository;
    this.varInfoNames = new HashSet<>();
    this.taglibsMap = new HashMap<>();
    this.jspPrefixMapper = new HashMap<>();
    this.xmlPrefixMapper = new HashMap<>();
    this.nonCustomTagPrefixMap = new HashMap<>();
    this.imports = new Vector<>();
    this.dependants = new HashMap<>();
    this.includePrelude = new Vector<>();
    this.includeCoda = new Vector<>();
    this.pluginDcls = new Vector<>();
    this.prefixes = new HashSet<>();

    // Enter standard imports
    imports.addAll(Constants.STANDARD_IMPORTS);
}
 
Example #6
Source File: JspRuntimeLibrary.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public static void introspecthelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF)
                                    throws JasperException
{
    if( Constants.IS_SECURITY_ENABLED ) {
        try {
            PrivilegedIntrospectHelper dp =
                new PrivilegedIntrospectHelper(
                    bean,prop,value,request,param,ignoreMethodNF);
            AccessController.doPrivileged(dp);
        } catch( PrivilegedActionException pe) {
            Exception e = pe.getException();
            throw (JasperException)e;
        }
    } else {
        internalIntrospecthelper(
            bean,prop,value,request,param,ignoreMethodNF);
    }
}
 
Example #7
Source File: TagHandlerPool.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
protected void init(ServletConfig config) {
    int maxSize = -1;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        try {
            maxSize = Integer.parseInt(maxSizeS);
        } catch (Exception ex) {
            maxSize = -1;
        }
    }
    if (maxSize < 0) {
        maxSize = Constants.MAX_POOL_SIZE;
    }
    this.handlers = new Tag[maxSize];
    this.current = -1;
    instanceManager = InstanceManagerFactory.getInstanceManager(config);
}
 
Example #8
Source File: TldCache.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
public TldCache(ServletContext servletContext,
        Map<String, TldResourcePath> uriTldResourcePathMap,
        Map<TldResourcePath, TaglibXml> tldResourcePathTaglibXmlMap) {
    this.servletContext = servletContext;
    this.uriTldResourcePathMap.putAll(uriTldResourcePathMap);
    for (Entry<TldResourcePath, TaglibXml> entry : tldResourcePathTaglibXmlMap.entrySet()) {
        TldResourcePath tldResourcePath = entry.getKey();
        long lastModified[] = getLastModified(tldResourcePath);
        TaglibXmlCacheEntry cacheEntry = new TaglibXmlCacheEntry(
                entry.getValue(), lastModified[0], lastModified[1]);
        this.tldResourcePathTaglibXmlMap.put(tldResourcePath, cacheEntry);
    }
    boolean validate = Boolean.parseBoolean(
            servletContext.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
    String blockExternalString = servletContext.getInitParameter(
            Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }
    tldParser = new TldParser(true, validate, blockExternal);
}
 
Example #9
Source File: PageInfo.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
PageInfo(BeanRepository beanRepository, String jspFile, boolean isTagFile) {
    this.isTagFile = isTagFile;
    this.jspFile = jspFile;
    this.beanRepository = beanRepository;
    this.varInfoNames = new HashSet<String>();
    this.taglibsMap = new HashMap<String, TagLibraryInfo>();
    this.jspPrefixMapper = new HashMap<String, String>();
    this.xmlPrefixMapper = new HashMap<String, LinkedList<String>>();
    this.nonCustomTagPrefixMap = new HashMap<String, Mark>();
    this.imports = new Vector<String>();
    this.dependants = new HashMap<String,Long>();
    this.includePrelude = new Vector<String>();
    this.includeCoda = new Vector<String>();
    this.pluginDcls = new Vector<String>();
    this.prefixes = new HashSet<String>();

    // Enter standard imports
    imports.addAll(Constants.STANDARD_IMPORTS);
}
 
Example #10
Source File: PageInfo.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
PageInfo(BeanRepository beanRepository, String jspFile, boolean isTagFile) {
    this.isTagFile = isTagFile;
    this.jspFile = jspFile;
    this.beanRepository = beanRepository;
    this.varInfoNames = new HashSet<String>();
    this.taglibsMap = new HashMap<String, TagLibraryInfo>();
    this.jspPrefixMapper = new HashMap<String, String>();
    this.xmlPrefixMapper = new HashMap<String, LinkedList<String>>();
    this.nonCustomTagPrefixMap = new HashMap<String, Mark>();
    this.imports = new Vector<String>();
    this.dependants = new HashMap<String,Long>();
    this.includePrelude = new Vector<String>();
    this.includeCoda = new Vector<String>();
    this.pluginDcls = new Vector<String>();
    this.prefixes = new HashSet<String>();

    // Enter standard imports
    imports.addAll(Constants.STANDARD_IMPORTS);
}
 
Example #11
Source File: JspFactoryImpl.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public PageContext getPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {

    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                this, servlet, request, response, errorPageURL,
                needsSession, bufferSize, autoflush);
        return AccessController.doPrivileged(dp);
    } else {
        return internalGetPageContext(servlet, request, response,
                errorPageURL, needsSession,
                bufferSize, autoflush);
    }
}
 
Example #12
Source File: PerThreadTagHandlerPool.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
protected void init(ServletConfig config) {
    maxSize = Constants.MAX_POOL_SIZE;
    String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
    if (maxSizeS != null) {
        maxSize = Integer.parseInt(maxSizeS);
        if (maxSize < 0) {
            maxSize = Constants.MAX_POOL_SIZE;
        }
    }

    perThread = new ThreadLocal<PerThreadData>() {
        @Override
        protected PerThreadData initialValue() {
            PerThreadData ptd = new PerThreadData();
            ptd.handlers = new Tag[maxSize];
            ptd.current = -1;
            perThreadDataVector.addElement(ptd);
            return ptd;
        }
    };
}
 
Example #13
Source File: ELFunctionMapper.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Convert a binary class name into a canonical one that can be used
 * when generating Java source code.
 * 
 * @param className Binary class name
 * @return          Canonical equivalent
 */
private String getCanonicalName(String className) throws JasperException {
    Class<?> clazz;
    
    ClassLoader tccl;
    if (Constants.IS_SECURITY_ENABLED) {
        PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl();
        tccl = AccessController.doPrivileged(pa);
    } else {
        tccl = Thread.currentThread().getContextClassLoader();
    }

    try {
        clazz = Class.forName(className, false, tccl);
    } catch (ClassNotFoundException e) {
        throw new JasperException(e);
    }
    return clazz.getCanonicalName();
}
 
Example #14
Source File: Generator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private void writeNewInstance(String tagHandlerVar, String tagHandlerClassName) {
    if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
        out.printin(tagHandlerClassName);
        out.print(" ");
        out.print(tagHandlerVar);
        out.print(" = (");
        out.print(tagHandlerClassName);
        out.print(")");
        out.print("_jsp_getInstanceManager().newInstance(\"");
        out.print(tagHandlerClassName);
        out.println("\", this.getClass().getClassLoader());");
    } else {
        out.printin(tagHandlerClassName);
        out.print(" ");
        out.print(tagHandlerVar);
        out.print(" = (");
        out.print("new ");
        out.print(tagHandlerClassName);
        out.println("());");
        out.printin("_jsp_getInstanceManager().newInstance(");
        out.print(tagHandlerVar);
        out.println(");");
    }
}
 
Example #15
Source File: TagHandlerPool.java    From packagedrone with Eclipse Public License 1.0 6 votes vote down vote up
protected void init( ServletConfig config ) {
    int maxSize=-1;
    String maxSizeS=getOption(config, OPTION_MAXSIZE, null);
    if( maxSizeS != null ) {
        try {
            maxSize=Integer.parseInt(maxSizeS);
        } catch( Exception ex) {
            maxSize=-1;
        }
    }
    if( maxSize <0  ) {
        maxSize=Constants.MAX_POOL_SIZE;
    }
    this.handlers = new JspTag[maxSize];
    this.current = -1;

    this.resourceInjector = (ResourceInjector)
        config.getServletContext().getAttribute(
            Constants.JSP_RESOURCE_INJECTOR_CONTEXT_ATTRIBUTE);
}
 
Example #16
Source File: JspDocumentParser.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public JspDocumentParser(
    ParserController pc,
    String path,
    boolean isTagFile,
    boolean directivesOnly) {
    this.parserController = pc;
    this.ctxt = pc.getJspCompilationContext();
    this.pageInfo = pc.getCompiler().getPageInfo();
    this.err = pc.getCompiler().getErrorDispatcher();
    this.path = path;
    this.isTagFile = isTagFile;
    this.directivesOnly = directivesOnly;
    this.isTop = true;

    String blockExternalString = ctxt.getServletContext().getInitParameter(
            Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }

    this.entityResolver = new LocalResolver(
            DigesterFactory.SERVLET_API_PUBLIC_IDS,
            DigesterFactory.SERVLET_API_SYSTEM_IDS,
            blockExternal);
}
 
Example #17
Source File: JspApplicationContextImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public void addELResolver(ELResolver resolver) {
    if ("true".equals(context.getAttribute(Constants.FIRST_REQUEST_SEEN))) {
        throw new IllegalStateException("Attempt to invoke addELResolver "
            + "after the application has already received a request");
    }

    elResolvers.add(0, resolver);
}
 
Example #18
Source File: JspFactoryImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void releasePageContext(PageContext pc) {
    if( pc == null )
        return;
    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
                this,pc);
        AccessController.doPrivileged(dp);
    } else {
        internalReleasePageContext(pc);
    }
}
 
Example #19
Source File: SecurityUtil.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
        return true;
    }
    return false;
}
 
Example #20
Source File: JspFactoryImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public void releasePageContext(PageContext pc) {
if( pc == null )
    return;
       if (Constants.IS_SECURITY_ENABLED) {
           PrivilegedReleasePageContext dp =
                   new PrivilegedReleasePageContext(this, pc);
           AccessController.doPrivileged(dp);
       } else {
           internalReleasePageContext(pc);
}
   }
 
Example #21
Source File: JspFactoryImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public JspApplicationContext getJspApplicationContext(
        final ServletContext context) {
    if (Constants.IS_SECURITY_ENABLED) {
        return AccessController.doPrivileged(
                new PrivilegedAction<JspApplicationContext>() {
            @Override
            public JspApplicationContext run() {
                return JspApplicationContextImpl.getInstance(context);
            }
        });
    } else {
        return JspApplicationContextImpl.getInstance(context);
    }
}
 
Example #22
Source File: Util.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Strips a servlet session ID from <tt>url</tt>.  The session ID
 * is encoded as a URL "path parameter" beginning with "jsessionid=".
 * We thus remove anything we find between ";jsessionid=" (inclusive)
 * and either EOS or a subsequent ';' (exclusive).
 * 
 * taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
 */
public static String stripSession(String url) {
    StringBuilder u = new StringBuilder(url);
    int sessionStart;
    while ((sessionStart = u.toString().indexOf(";" + Constants.SESSION_PARAMETER_NAME + "=")) != -1) {
        int sessionEnd = u.toString().indexOf(';', sessionStart + 1);
        if (sessionEnd == -1)
            sessionEnd = u.toString().indexOf('?', sessionStart + 1);
        if (sessionEnd == -1) // still
            sessionEnd = u.length();
        u.delete(sessionStart, sessionEnd);
    }
    return u.toString();
}
 
Example #23
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private void _initialize(Servlet servlet,
		     ServletRequest request,
		     ServletResponse response,
		     String errorPageURL,
		     boolean needsSession,
		     int bufferSize,
		     boolean autoFlush) throws IOException {

// initialize state
this.servlet = servlet;
this.config = servlet.getServletConfig();
this.context = config.getServletContext();
this.needsSession = needsSession;
this.errorPageURL = errorPageURL;
this.bufferSize = bufferSize;
this.request = request;
	this.response = response;

// Setup session (if required)
if (request instanceof HttpServletRequest && needsSession)
    this.session = ((HttpServletRequest)request).getSession();
if (needsSession && session == null)
    throw new IllegalStateException
               ("Page needs a session and none is available");

       // initialize the initial out ...
       depth = -1;
       if (this.baseOut == null) {
           this.baseOut = new JspWriterImpl(response, bufferSize, autoFlush);
       } else {
           this.baseOut.init(response, bufferSize, autoFlush);
       }
       this.out = baseOut;

       this.isNametableInitialized = false;
       setAttribute(Constants.FIRST_REQUEST_SEEN, "true", APPLICATION_SCOPE);

   }
 
Example #24
Source File: JspUtil.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private static String getClassNameBase(String urn) {
    StringBuilder base =
            new StringBuilder(Constants.TAG_FILE_PACKAGE_NAME + ".meta.");
    if (urn != null) {
        base.append(makeJavaPackage(urn));
        base.append('.');
    }
    return base.toString();
}
 
Example #25
Source File: SecurityUtil.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
        return true;
    }
    return false;
}
 
Example #26
Source File: PageContextImpl.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public void forward(String relativeUrlPath)
    throws ServletException, IOException{

    // JSP.4.5 If the buffer was flushed, throw IllegalStateException
    try {
        out.clear();
    } catch (IOException ex) {
        IllegalStateException ise =
            new IllegalStateException(Localizer.getMessage(
                        "jsp.error.attempt_to_clear_flushed_buffer"));
        ise.initCause(ex);
        throw ise;
    }

    // Make sure that the response object is not the wrapper for include
    while (response instanceof ServletResponseWrapperInclude) {
        response = ((ServletResponseWrapperInclude)response).getResponse();
    }

    final String path = getAbsolutePathRelativeToContext(relativeUrlPath);
    String includeUri
        = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
        
    final ServletResponse fresponse = response;
    final ServletRequest frequest = request;
        
    if (includeUri != null)
        request.removeAttribute(Constants.INC_SERVLET_PATH);
    try {
        context.getRequestDispatcher(path).forward(request, response);
    } finally {
        if (includeUri != null)
            request.setAttribute(Constants.INC_SERVLET_PATH, includeUri);
        request.setAttribute(Constants.FORWARD_SEEN, "true");
    }
}
 
Example #27
Source File: SecurityUtil.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Return the <code>SecurityManager</code> only if Security is enabled AND
 * package protection mechanism is enabled.
 * @return <code>true</code> if package protection is enabled
 */
public static boolean isPackageProtectionEnabled(){
    if (packageDefinitionEnabled && Constants.IS_SECURITY_ENABLED){
        return true;
    }
    return false;
}
 
Example #28
Source File: TagHandlerPool.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the next available tag handler from this tag handler pool,
 * instantiating one if this tag handler pool is empty.
 * 
 * @param handlerClass
 *            Tag handler class
 * @return Reused or newly instantiated tag handler
 * @throws JspException
 *             if a tag handler cannot be instantiated
 */
public Tag get(Class<? extends Tag> handlerClass) throws JspException {
    Tag handler;
    synchronized (this) {
        if (current >= 0) {
            handler = handlers[current--];
            return handler;
        }
    }

    // Out of sync block - there is no need for other threads to
    // wait for us to construct a tag for this thread.
    try {
        if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
            return (Tag) instanceManager.newInstance(
                    handlerClass.getName(), handlerClass.getClassLoader());
        } else {
            Tag instance = handlerClass.newInstance();
            instanceManager.newInstance(instance);
            return instance;
        }
    } catch (Exception e) {
        Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
        ExceptionUtils.handleThrowable(t);
        throw new JspException(e.getMessage(), t);
    }
}
 
Example #29
Source File: BodyContentImpl.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Clear the contents of the buffer. If the buffer has been already
 * been flushed then the clear operation shall throw an IOException
 * to signal the fact that some data has already been irrevocably 
 * written to the client response stream.
 *
 * @throws IOException If an I/O error occurs
 */
@Override
public void clear() throws IOException {
    if (writer != null) {
        throw new IOException();
    } else {
        nextChar = 0;
        if (LIMIT_BUFFER && (cb.length > Constants.DEFAULT_TAG_BUFFER_SIZE)) {
            cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE];
            bufferSize = cb.length;
        }
    }
}
 
Example #30
Source File: Util.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Strips a servlet session ID from <tt>url</tt>.  The session ID
 * is encoded as a URL "path parameter" beginning with "jsessionid=".
 * We thus remove anything we find between ";jsessionid=" (inclusive)
 * and either EOS or a subsequent ';' (exclusive).
 * 
 * taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
 */
public static String stripSession(String url) {
    StringBuilder u = new StringBuilder(url);
    int sessionStart;
    while ((sessionStart = u.toString().indexOf(";" + Constants.SESSION_PARAMETER_NAME + "=")) != -1) {
        int sessionEnd = u.toString().indexOf(';', sessionStart + 1);
        if (sessionEnd == -1)
            sessionEnd = u.toString().indexOf('?', sessionStart + 1);
        if (sessionEnd == -1) // still
            sessionEnd = u.length();
        u.delete(sessionStart, sessionEnd);
    }
    return u.toString();
}