| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Tomcat example source code file (

This example Tomcat source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Tomcat tags/keywords

arraylist, compositeelresolver, elcontextevent, elcontextimpl, elcontextimpl, elresolver, elresolver, expressionfactory, http, illegalargumentexception, illegalargumentexception, illegalstateexception, jsp, jspapplicationcontextimpl, jspapplicationcontextimpl, list, servlet, util

The Tomcat source code

 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.apache.jasper.runtime;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.el.ArrayELResolver;
import javax.el.BeanELResolver;
import javax.el.CompositeELResolver;
import javax.el.ELContextEvent;
import javax.el.ELContextListener;
import javax.el.ELResolver;
import javax.el.ExpressionFactory;
import javax.el.ListELResolver;
import javax.el.MapELResolver;
import javax.el.ResourceBundleELResolver;
import javax.servlet.ServletContext;
import javax.servlet.jsp.JspApplicationContext;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.el.ImplicitObjectELResolver;
import javax.servlet.jsp.el.ScopedAttributeELResolver;

import org.apache.el.ExpressionFactoryImpl;
import org.apache.jasper.el.ELContextImpl;

 * Implementation of JspApplicationContext
 * @author Jacob Hookom
public class JspApplicationContextImpl implements JspApplicationContext {

	private final static String KEY = JspApplicationContextImpl.class.getName();

	private final static ExpressionFactory expressionFactory = new ExpressionFactoryImpl();

	private final List<ELContextListener> contextListeners = new ArrayList();

	private final List<ELResolver> resolvers = new ArrayList();

	private boolean instantiated = false;

	private ELResolver resolver;

	public JspApplicationContextImpl() {


	public void addELContextListener(ELContextListener listener) {
		if (listener == null) {
			throw new IllegalArgumentException("ELConextListener was null");

	public static JspApplicationContextImpl getInstance(ServletContext context) {
		if (context == null) {
			throw new IllegalArgumentException("ServletContext was null");
		JspApplicationContextImpl impl = (JspApplicationContextImpl) context
		if (impl == null) {
			impl = new JspApplicationContextImpl();
			context.setAttribute(KEY, impl);
		return impl;

	public ELContextImpl createELContext(JspContext context) {
		if (context == null) {
			throw new IllegalArgumentException("JspContext was null");

		// create ELContext for JspContext
		ELResolver r = this.createELResolver();
		ELContextImpl ctx = new ELContextImpl(r);
		ctx.putContext(JspContext.class, context);

		// alert all ELContextListeners
		ELContextEvent event = new ELContextEvent(ctx);
		for (int i = 0; i < this.contextListeners.size(); i++) {

		return ctx;

	private ELResolver createELResolver() {
		this.instantiated = true;
		if (this.resolver == null) {
			CompositeELResolver r = new CompositeELResolver();
			r.add(new ImplicitObjectELResolver());
			for (Iterator itr = this.resolvers.iterator(); itr.hasNext();) {
			r.add(new MapELResolver());
			r.add(new ResourceBundleELResolver());
			r.add(new ListELResolver());
			r.add(new ArrayELResolver());	
			r.add(new BeanELResolver());
			r.add(new ScopedAttributeELResolver());
			this.resolver = r;
		return this.resolver;

	public void addELResolver(ELResolver resolver) throws IllegalStateException {
		if (resolver == null) {
			throw new IllegalArgumentException("ELResolver was null");
		if (this.instantiated) {
			throw new IllegalStateException(
					"cannot call addELResolver after the first request has been made");

	public ExpressionFactory getExpressionFactory() {
		return expressionFactory;


Other Tomcat examples (source code examples)

Here is a short list of links related to this Tomcat source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.