You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2006/05/29 13:51:43 UTC

svn commit: r410080 [2/6] - in /tomcat/tc6.0.x/trunk/webapps/examples: ./ WEB-INF/ WEB-INF/classes/ WEB-INF/classes/cal/ WEB-INF/classes/chat/ WEB-INF/classes/checkbox/ WEB-INF/classes/colors/ WEB-INF/classes/compressionFilters/ WEB-INF/classes/dates/ ...

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilter.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilter.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilter.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilter.java Mon May 29 04:51:34 2006
@@ -0,0 +1,218 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package compressionFilters;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Implementation of <code>javax.servlet.Filter</code> used to compress
+ * the ServletResponse if it is bigger than a threshold.
+ *
+ * @author Amy Roh
+ * @author Dmitri Valdin
+ * @version $Revision: 267129 $, $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public class CompressionFilter implements Filter{
+
+    /**
+     * The filter configuration object we are associated with.  If this value
+     * is null, this filter instance is not currently configured.
+     */
+    private FilterConfig config = null;
+
+    /**
+     * Minimal reasonable threshold
+     */
+    private int minThreshold = 128;
+
+
+    /**
+     * The threshold number to compress
+     */
+    protected int compressionThreshold;
+
+    /**
+     * Debug level for this filter
+     */
+    private int debug = 0;
+
+    /**
+     * Place this filter into service.
+     *
+     * @param filterConfig The filter configuration object
+     */
+
+    public void init(FilterConfig filterConfig) {
+
+        config = filterConfig;
+        if (filterConfig != null) {
+            String value = filterConfig.getInitParameter("debug");
+            if (value!=null) {
+                debug = Integer.parseInt(value);
+            } else {
+                debug = 0;
+            }
+            String str = filterConfig.getInitParameter("compressionThreshold");
+            if (str!=null) {
+                compressionThreshold = Integer.parseInt(str);
+                if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
+                    if (debug > 0) {
+                        System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
+                        System.out.println("compressionThreshold set to " + minThreshold);
+                    }
+                    compressionThreshold = minThreshold;
+                }
+            } else {
+                compressionThreshold = 0;
+            }
+
+        } else {
+            compressionThreshold = 0;
+        }
+
+    }
+
+    /**
+    * Take this filter out of service.
+    */
+    public void destroy() {
+
+        this.config = null;
+
+    }
+
+    /**
+     * The <code>doFilter</code> method of the Filter is called by the container
+     * each time a request/response pair is passed through the chain due
+     * to a client request for a resource at the end of the chain.
+     * The FilterChain passed into this method allows the Filter to pass on the
+     * request and response to the next entity in the chain.<p>
+     * This method first examines the request to check whether the client support
+     * compression. <br>
+     * It simply just pass the request and response if there is no support for
+     * compression.<br>
+     * If the compression support is available, it creates a
+     * CompressionServletResponseWrapper object which compresses the content and
+     * modifies the header if the content length is big enough.
+     * It then invokes the next entity in the chain using the FilterChain object
+     * (<code>chain.doFilter()</code>), <br>
+     **/
+
+    public void doFilter ( ServletRequest request, ServletResponse response,
+                        FilterChain chain ) throws IOException, ServletException {
+
+        if (debug > 0) {
+            System.out.println("@doFilter");
+        }
+
+        if (compressionThreshold == 0) {
+            if (debug > 0) {
+                System.out.println("doFilter gets called, but compressionTreshold is set to 0 - no compression");
+            }
+            chain.doFilter(request, response);
+            return;
+        }
+
+        boolean supportCompression = false;
+        if (request instanceof HttpServletRequest) {
+            if (debug > 1) {
+                System.out.println("requestURI = " + ((HttpServletRequest)request).getRequestURI());
+            }
+
+            // Are we allowed to compress ?
+            String s = (String) ((HttpServletRequest)request).getParameter("gzip");
+            if ("false".equals(s)) {
+                if (debug > 0) {
+                    System.out.println("got parameter gzip=false --> don't compress, just chain filter");
+                }
+                chain.doFilter(request, response);
+                return;
+            }
+
+            Enumeration e =
+                ((HttpServletRequest)request).getHeaders("Accept-Encoding");
+            while (e.hasMoreElements()) {
+                String name = (String)e.nextElement();
+                if (name.indexOf("gzip") != -1) {
+                    if (debug > 0) {
+                        System.out.println("supports compression");
+                    }
+                    supportCompression = true;
+                } else {
+                    if (debug > 0) {
+                        System.out.println("no support for compresion");
+                    }
+                }
+            }
+        }
+
+        if (!supportCompression) {
+            if (debug > 0) {
+                System.out.println("doFilter gets called wo compression");
+            }
+            chain.doFilter(request, response);
+            return;
+        } else {
+            if (response instanceof HttpServletResponse) {
+                CompressionServletResponseWrapper wrappedResponse =
+                    new CompressionServletResponseWrapper((HttpServletResponse)response);
+                wrappedResponse.setDebugLevel(debug);
+                wrappedResponse.setCompressionThreshold(compressionThreshold);
+                if (debug > 0) {
+                    System.out.println("doFilter gets called with compression");
+                }
+                try {
+                    chain.doFilter(request, wrappedResponse);
+                } finally {
+                    wrappedResponse.finishResponse();
+                }
+                return;
+            }
+        }
+    }
+
+    /**
+     * Set filter config
+     * This function is equivalent to init. Required by Weblogic 6.1
+     *
+     * @param filterConfig The filter configuration object
+     */
+    public void setFilterConfig(FilterConfig filterConfig) {
+        init(filterConfig);
+    }
+
+    /**
+     * Return filter config
+     * Required by Weblogic 6.1
+     */
+    public FilterConfig getFilterConfig() {
+        return config;
+    }
+
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java Mon May 29 04:51:34 2006
@@ -0,0 +1,57 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package compressionFilters;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+/**
+ * Very Simple test servlet to test compression filter
+ * @author Amy Roh
+ * @version $Revision: 267129 $, $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public class CompressionFilterTestServlet extends HttpServlet {
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+        throws ServletException, IOException {
+
+        ServletOutputStream out = response.getOutputStream();
+        response.setContentType("text/plain");
+
+        Enumeration e = ((HttpServletRequest)request).getHeaders("Accept-Encoding");
+        while (e.hasMoreElements()) {
+            String name = (String)e.nextElement();
+            out.println(name);
+            if (name.indexOf("gzip") != -1) {
+                out.println("gzip supported -- able to compress");
+            }
+            else {
+                out.println("gzip not supported");
+            }
+        }
+
+
+        out.println("Compression Filter Test Servlet");
+        out.close();
+    }
+
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java Mon May 29 04:51:34 2006
@@ -0,0 +1,317 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package compressionFilters;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.GZIPOutputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * Implementation of <b>ServletOutputStream</b> that works with
+ * the CompressionServletResponseWrapper implementation.
+ *
+ * @author Amy Roh
+ * @author Dmitri Valdin
+ * @version $Revision: 267129 $, $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public class CompressionResponseStream
+    extends ServletOutputStream {
+
+
+    // ----------------------------------------------------------- Constructors
+
+
+    /**
+     * Construct a servlet output stream associated with the specified Response.
+     *
+     * @param response The associated response
+     */
+    public CompressionResponseStream(HttpServletResponse response) throws IOException{
+
+        super();
+        closed = false;
+        this.response = response;
+        this.output = response.getOutputStream();
+
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * The threshold number which decides to compress or not.
+     * Users can configure in web.xml to set it to fit their needs.
+     */
+    protected int compressionThreshold = 0;
+
+    /**
+     * Debug level
+     */
+    private int debug = 0;
+
+    /**
+     * The buffer through which all of our output bytes are passed.
+     */
+    protected byte[] buffer = null;
+
+    /**
+     * The number of data bytes currently in the buffer.
+     */
+    protected int bufferCount = 0;
+
+    /**
+     * The underlying gzip output stream to which we should write data.
+     */
+    protected GZIPOutputStream gzipstream = null;
+
+    /**
+     * Has this stream been closed?
+     */
+    protected boolean closed = false;
+
+    /**
+     * The content length past which we will not write, or -1 if there is
+     * no defined content length.
+     */
+    protected int length = -1;
+
+    /**
+     * The response with which this servlet output stream is associated.
+     */
+    protected HttpServletResponse response = null;
+
+    /**
+     * The underlying servket output stream to which we should write data.
+     */
+    protected ServletOutputStream output = null;
+
+
+    // --------------------------------------------------------- Public Methods
+
+    /**
+     * Set debug level
+     */
+    public void setDebugLevel(int debug) {
+        this.debug = debug;
+    }
+
+
+    /**
+     * Set the compressionThreshold number and create buffer for this size
+     */
+    protected void setBuffer(int threshold) {
+        compressionThreshold = threshold;
+        buffer = new byte[compressionThreshold];
+        if (debug > 1) {
+            System.out.println("buffer is set to "+compressionThreshold);
+        }
+    }
+
+    /**
+     * Close this output stream, causing any buffered data to be flushed and
+     * any further output data to throw an IOException.
+     */
+    public void close() throws IOException {
+
+        if (debug > 1) {
+            System.out.println("close() @ CompressionResponseStream");
+        }
+        if (closed)
+            throw new IOException("This output stream has already been closed");
+
+        if (gzipstream != null) {
+            flushToGZip();
+            gzipstream.close();
+            gzipstream = null;
+        } else {
+            if (bufferCount > 0) {
+                if (debug > 2) {
+                    System.out.print("output.write(");
+                    System.out.write(buffer, 0, bufferCount);
+                    System.out.println(")");
+                }
+                output.write(buffer, 0, bufferCount);
+                bufferCount = 0;
+            }
+        }
+
+        output.close();
+        closed = true;
+
+    }
+
+
+    /**
+     * Flush any buffered data for this output stream, which also causes the
+     * response to be committed.
+     */
+    public void flush() throws IOException {
+
+        if (debug > 1) {
+            System.out.println("flush() @ CompressionResponseStream");
+        }
+        if (closed) {
+            throw new IOException("Cannot flush a closed output stream");
+        }
+
+        if (gzipstream != null) {
+            gzipstream.flush();
+        }
+
+    }
+
+    public void flushToGZip() throws IOException {
+
+        if (debug > 1) {
+            System.out.println("flushToGZip() @ CompressionResponseStream");
+        }
+        if (bufferCount > 0) {
+            if (debug > 1) {
+                System.out.println("flushing out to GZipStream, bufferCount = " + bufferCount);
+            }
+            writeToGZip(buffer, 0, bufferCount);
+            bufferCount = 0;
+        }
+
+    }
+
+    /**
+     * Write the specified byte to our output stream.
+     *
+     * @param b The byte to be written
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public void write(int b) throws IOException {
+
+        if (debug > 1) {
+            System.out.println("write "+b+" in CompressionResponseStream ");
+        }
+        if (closed)
+            throw new IOException("Cannot write to a closed output stream");
+
+        if (bufferCount >= buffer.length) {
+            flushToGZip();
+        }
+
+        buffer[bufferCount++] = (byte) b;
+
+    }
+
+
+    /**
+     * Write <code>b.length</code> bytes from the specified byte array
+     * to our output stream.
+     *
+     * @param b The byte array to be written
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public void write(byte b[]) throws IOException {
+
+        write(b, 0, b.length);
+
+    }
+
+
+    /**
+     * Write <code>len</code> bytes from the specified byte array, starting
+     * at the specified offset, to our output stream.
+     *
+     * @param b The byte array containing the bytes to be written
+     * @param off Zero-relative starting offset of the bytes to be written
+     * @param len The number of bytes to be written
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public void write(byte b[], int off, int len) throws IOException {
+
+        if (debug > 1) {
+            System.out.println("write, bufferCount = " + bufferCount + " len = " + len + " off = " + off);
+        }
+        if (debug > 2) {
+            System.out.print("write(");
+            System.out.write(b, off, len);
+            System.out.println(")");
+        }
+
+        if (closed)
+            throw new IOException("Cannot write to a closed output stream");
+
+        if (len == 0)
+            return;
+
+        // Can we write into buffer ?
+        if (len <= (buffer.length - bufferCount)) {
+            System.arraycopy(b, off, buffer, bufferCount, len);
+            bufferCount += len;
+            return;
+        }
+
+        // There is not enough space in buffer. Flush it ...
+        flushToGZip();
+
+        // ... and try again. Note, that bufferCount = 0 here !
+        if (len <= (buffer.length - bufferCount)) {
+            System.arraycopy(b, off, buffer, bufferCount, len);
+            bufferCount += len;
+            return;
+        }
+
+        // write direct to gzip
+        writeToGZip(b, off, len);
+    }
+
+    public void writeToGZip(byte b[], int off, int len) throws IOException {
+
+        if (debug > 1) {
+            System.out.println("writeToGZip, len = " + len);
+        }
+        if (debug > 2) {
+            System.out.print("writeToGZip(");
+            System.out.write(b, off, len);
+            System.out.println(")");
+        }
+        if (gzipstream == null) {
+            if (debug > 1) {
+                System.out.println("new GZIPOutputStream");
+            }
+            response.addHeader("Content-Encoding", "gzip");
+            gzipstream = new GZIPOutputStream(output);
+        }
+        gzipstream.write(b, off, len);
+
+    }
+
+
+    // -------------------------------------------------------- Package Methods
+
+
+    /**
+     * Has this response stream been closed?
+     */
+    public boolean closed() {
+
+        return (this.closed);
+
+    }
+
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java Mon May 29 04:51:34 2006
@@ -0,0 +1,276 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package compressionFilters;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Locale;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.ServletResponseWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+/**
+ * Implementation of <b>HttpServletResponseWrapper</b> that works with
+ * the CompressionServletResponseStream implementation..
+ *
+ * @author Amy Roh
+ * @author Dmitri Valdin
+ * @version $Revision: 267129 $, $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public class CompressionServletResponseWrapper extends HttpServletResponseWrapper {
+
+    // ----------------------------------------------------- Constructor
+
+    /**
+     * Calls the parent constructor which creates a ServletResponse adaptor
+     * wrapping the given response object.
+     */
+
+    public CompressionServletResponseWrapper(HttpServletResponse response) {
+        super(response);
+        origResponse = response;
+        if (debug > 1) {
+            System.out.println("CompressionServletResponseWrapper constructor gets called");
+        }
+    }
+
+
+    // ----------------------------------------------------- Instance Variables
+
+    /**
+     * Original response
+     */
+
+    protected HttpServletResponse origResponse = null;
+
+    /**
+     * Descriptive information about this Response implementation.
+     */
+
+    protected static final String info = "CompressionServletResponseWrapper";
+
+    /**
+     * The ServletOutputStream that has been returned by
+     * <code>getOutputStream()</code>, if any.
+     */
+
+    protected ServletOutputStream stream = null;
+
+
+    /**
+     * The PrintWriter that has been returned by
+     * <code>getWriter()</code>, if any.
+     */
+
+    protected PrintWriter writer = null;
+
+    /**
+     * The threshold number to compress
+     */
+    protected int threshold = 0;
+
+    /**
+     * Debug level
+     */
+    private int debug = 0;
+
+    /**
+     * Content type
+     */
+    protected String contentType = null;
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Set content type
+     */
+    public void setContentType(String contentType) {
+        if (debug > 1) {
+            System.out.println("setContentType to "+contentType);
+        }
+        this.contentType = contentType;
+        origResponse.setContentType(contentType);
+    }
+
+
+    /**
+     * Set threshold number
+     */
+    public void setCompressionThreshold(int threshold) {
+        if (debug > 1) {
+            System.out.println("setCompressionThreshold to " + threshold);
+        }
+        this.threshold = threshold;
+    }
+
+
+    /**
+     * Set debug level
+     */
+    public void setDebugLevel(int debug) {
+        this.debug = debug;
+    }
+
+
+    /**
+     * Create and return a ServletOutputStream to write the content
+     * associated with this Response.
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public ServletOutputStream createOutputStream() throws IOException {
+        if (debug > 1) {
+            System.out.println("createOutputStream gets called");
+        }
+
+        CompressionResponseStream stream = new CompressionResponseStream(origResponse);
+        stream.setDebugLevel(debug);
+        stream.setBuffer(threshold);
+
+        return stream;
+
+    }
+
+
+    /**
+     * Finish a response.
+     */
+    public void finishResponse() {
+        try {
+            if (writer != null) {
+                writer.close();
+            } else {
+                if (stream != null)
+                    stream.close();
+            }
+        } catch (IOException e) {
+        }
+    }
+
+
+    // ------------------------------------------------ ServletResponse Methods
+
+
+    /**
+     * Flush the buffer and commit this response.
+     *
+     * @exception IOException if an input/output error occurs
+     */
+    public void flushBuffer() throws IOException {
+        if (debug > 1) {
+            System.out.println("flush buffer @ CompressionServletResponseWrapper");
+        }
+        ((CompressionResponseStream)stream).flush();
+
+    }
+
+    /**
+     * Return the servlet output stream associated with this Response.
+     *
+     * @exception IllegalStateException if <code>getWriter</code> has
+     *  already been called for this response
+     * @exception IOException if an input/output error occurs
+     */
+    public ServletOutputStream getOutputStream() throws IOException {
+
+        if (writer != null)
+            throw new IllegalStateException("getWriter() has already been called for this response");
+
+        if (stream == null)
+            stream = createOutputStream();
+        if (debug > 1) {
+            System.out.println("stream is set to "+stream+" in getOutputStream");
+        }
+
+        return (stream);
+
+    }
+
+    /**
+     * Return the writer associated with this Response.
+     *
+     * @exception IllegalStateException if <code>getOutputStream</code> has
+     *  already been called for this response
+     * @exception IOException if an input/output error occurs
+     */
+    public PrintWriter getWriter() throws IOException {
+
+        if (writer != null)
+            return (writer);
+
+        if (stream != null)
+            throw new IllegalStateException("getOutputStream() has already been called for this response");
+
+        stream = createOutputStream();
+        if (debug > 1) {
+            System.out.println("stream is set to "+stream+" in getWriter");
+        }
+        //String charset = getCharsetFromContentType(contentType);
+        String charEnc = origResponse.getCharacterEncoding();
+        if (debug > 1) {
+            System.out.println("character encoding is " + charEnc);
+        }
+        // HttpServletResponse.getCharacterEncoding() shouldn't return null
+        // according the spec, so feel free to remove that "if"
+        if (charEnc != null) {
+            writer = new PrintWriter(new OutputStreamWriter(stream, charEnc));
+        } else {
+            writer = new PrintWriter(stream);
+        }
+        
+        return (writer);
+
+    }
+
+
+    public void setContentLength(int length) {
+    }
+
+
+    /**
+     * Returns character from content type. This method was taken from tomcat.
+     * @author rajo
+     */
+    private static String getCharsetFromContentType(String type) {
+
+        if (type == null) {
+            return null;
+        }
+        int semi = type.indexOf(";");
+        if (semi == -1) {
+            return null;
+        }
+        String afterSemi = type.substring(semi + 1);
+        int charsetLocation = afterSemi.indexOf("charset=");
+        if(charsetLocation == -1) {
+            return null;
+        } else {
+            String afterCharset = afterSemi.substring(charsetLocation + 8);
+            String encoding = afterCharset.trim();
+            return encoding;
+        }
+    }
+
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/dates/JspCalendar.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/dates/JspCalendar.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/dates/JspCalendar.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/dates/JspCalendar.java Mon May 29 04:51:34 2006
@@ -0,0 +1,152 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package dates;
+
+import java.text.DateFormat;
+import java.util.*;
+
+public class JspCalendar {
+    Calendar  calendar = null;
+
+    public JspCalendar() {
+	calendar = Calendar.getInstance();
+	Date trialTime = new Date();
+	calendar.setTime(trialTime);
+    }
+
+    public int getYear() {
+	return calendar.get(Calendar.YEAR);
+    }
+    
+    public String getMonth() {
+	int m = getMonthInt();
+	String[] months = new String [] { "January", "February", "March",
+					"April", "May", "June",
+					"July", "August", "September",
+					"October", "November", "December" };
+	if (m > 12)
+	    return "Unknown to Man";
+	
+	return months[m - 1];
+
+    }
+
+    public String getDay() {
+	int x = getDayOfWeek();
+	String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", 
+				      "Thursday", "Friday", "Saturday"};
+
+	if (x > 7)
+	    return "Unknown to Man";
+
+	return days[x - 1];
+
+    }
+    
+    public int getMonthInt() {
+	return 1 + calendar.get(Calendar.MONTH);
+    }
+
+    public String getDate() {
+	return getMonthInt() + "/" + getDayOfMonth() + "/" +  getYear();
+
+    }
+
+    public String getTime() {
+	return getHour() + ":" + getMinute() + ":" + getSecond();
+    }
+
+    public int getDayOfMonth() {
+	return calendar.get(Calendar.DAY_OF_MONTH);
+    }
+
+    public int getDayOfYear() {
+	return calendar.get(Calendar.DAY_OF_YEAR);
+    }
+
+    public int getWeekOfYear() {
+	return calendar.get(Calendar.WEEK_OF_YEAR);
+    }
+
+    public int getWeekOfMonth() {
+	return calendar.get(Calendar.WEEK_OF_MONTH);
+    }
+
+    public int getDayOfWeek() {
+	return calendar.get(Calendar.DAY_OF_WEEK);
+    }
+     
+    public int getHour() {
+	return calendar.get(Calendar.HOUR_OF_DAY);
+    }
+    
+    public int getMinute() {
+	return calendar.get(Calendar.MINUTE);
+    }
+
+
+    public int getSecond() {
+	return calendar.get(Calendar.SECOND);
+    }
+
+    public static void main(String args[]) {
+	JspCalendar db = new JspCalendar();
+	p("date: " + db.getDayOfMonth());
+	p("year: " + db.getYear());
+	p("month: " + db.getMonth());
+	p("time: " + db.getTime());
+	p("date: " + db.getDate());
+	p("Day: " + db.getDay());
+	p("DayOfYear: " + db.getDayOfYear());
+	p("WeekOfYear: " + db.getWeekOfYear());
+	p("era: " + db.getEra());
+	p("ampm: " + db.getAMPM());
+	p("DST: " + db.getDSTOffset());
+	p("ZONE Offset: " + db.getZoneOffset());
+	p("TIMEZONE: " + db.getUSTimeZone());
+    }
+
+    private static void p(String x) {
+	System.out.println(x);
+    }
+
+
+    public int getEra() {
+	return calendar.get(Calendar.ERA);
+    }
+
+    public String getUSTimeZone() {
+	String[] zones = new String[] {"Hawaii", "Alaskan", "Pacific",
+				       "Mountain", "Central", "Eastern"};
+	
+	return zones[10 + getZoneOffset()];
+    }
+
+    public int getZoneOffset() {
+	return calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000);
+    }
+
+
+    public int getDSTOffset() {
+	return calendar.get(Calendar.DST_OFFSET)/(60*60*1000);
+    }
+
+    
+    public int getAMPM() {
+	return calendar.get(Calendar.AM_PM);
+    }
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/dates/JspCalendar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/error/Smart.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/error/Smart.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/error/Smart.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/error/Smart.java Mon May 29 04:51:34 2006
@@ -0,0 +1,34 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package error;
+
+import java.io.*;
+import java.lang.*;
+
+public class Smart {
+
+  String name = "JSP";
+
+  public String getName () {
+	return name;
+  }	
+
+  public void setName (String name) {
+	this.name = name;
+  }	
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/error/Smart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ExampleTagBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ExampleTagBase.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ExampleTagBase.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ExampleTagBase.java Mon May 29 04:51:34 2006
@@ -0,0 +1,66 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package examples;
+
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.tagext.*;
+
+public abstract class ExampleTagBase extends BodyTagSupport {
+
+    public void setParent(Tag parent) {
+        this.parent = parent;
+    }
+
+    public void setBodyContent(BodyContent bodyOut) {
+        this.bodyOut = bodyOut;
+    }
+
+    public void setPageContext(PageContext pageContext) {
+        this.pageContext = pageContext;
+    }
+
+    public Tag getParent() {
+        return this.parent;
+    }
+    
+    public int doStartTag() throws JspException {
+        return SKIP_BODY;
+    }
+
+    public int doEndTag() throws JspException {
+        return EVAL_PAGE;
+    }
+    
+
+    // Default implementations for BodyTag methods as well
+    // just in case a tag decides to implement BodyTag.
+    public void doInitBody() throws JspException {
+    }
+
+    public int doAfterBody() throws JspException {
+        return SKIP_BODY;
+    }
+
+    public void release() {
+        bodyOut = null;
+        pageContext = null;
+        parent = null;
+    }
+    
+    protected BodyContent bodyOut;
+    protected PageContext pageContext;
+    protected Tag parent;
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ExampleTagBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,82 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package examples;
+
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.tagext.*;
+import java.util.Hashtable;
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * Example1: the simplest tag
+ * Collect attributes and call into some actions
+ *
+ * <foo att1="..." att2="...." att3="...." />
+ */
+
+public class FooTag 
+    extends ExampleTagBase 
+{
+    private String atts[] = new String[3];
+    int i = 0;
+    
+    private final void setAtt(int index, String value) {
+        atts[index] = value;
+    }
+    
+    public void setAtt1(String value) {
+        setAtt(0, value);
+    }
+    
+    public void setAtt2(String value) {
+        setAtt(1, value);
+    }
+
+    public void setAtt3(String value) {
+        setAtt(2, value);
+    }
+    
+    /**
+     * Process start tag
+     *
+     * @return EVAL_BODY_INCLUDE
+     */
+    public int doStartTag() throws JspException {
+        i = 0;
+	return EVAL_BODY_TAG;
+    }
+
+    public void doInitBody() throws JspException {
+        pageContext.setAttribute("member", atts[i]);
+        i++;
+    }
+    
+    public int doAfterBody() throws JspException {
+        try {
+            if (i == 3) {
+                bodyOut.writeOut(bodyOut.getEnclosingWriter());
+                return SKIP_BODY;
+            } else
+                pageContext.setAttribute("member", atts[i]);
+            i++;
+            return EVAL_BODY_TAG;
+        } catch (IOException ex) {
+            throw new JspTagException(ex.toString());
+        }
+    }
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTagExtraInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTagExtraInfo.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTagExtraInfo.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTagExtraInfo.java Mon May 29 04:51:34 2006
@@ -0,0 +1,32 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package examples;
+
+import javax.servlet.jsp.tagext.*;
+
+public class FooTagExtraInfo extends TagExtraInfo {
+    public VariableInfo[] getVariableInfo(TagData data) {
+        return new VariableInfo[] 
+            {
+                new VariableInfo("member",
+                                 "String",
+                                 true,
+                                 VariableInfo.NESTED)
+            };
+    }
+}
+
+        

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/FooTagExtraInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/LogTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/LogTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/LogTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/LogTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,60 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package examples;
+
+
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.tagext.*;
+
+import java.io.IOException;
+
+/**
+ * Log the contents of the body. Could be used to handle errors etc. 
+ */
+public class LogTag 
+    extends ExampleTagBase
+{
+    boolean toBrowser = false;
+    
+    public void setToBrowser(String value) {
+        if (value == null)
+            toBrowser = false;
+        else if (value.equalsIgnoreCase("true"))
+            toBrowser = true;
+        else
+            toBrowser = false;
+    }
+
+    public int doStartTag() throws JspException {
+        return EVAL_BODY_TAG;
+    }
+    
+    public int doAfterBody() throws JspException {
+        try {
+            String s = bodyOut.getString();
+            System.err.println(s);
+            if (toBrowser)
+                bodyOut.writeOut(bodyOut.getEnclosingWriter());
+            return SKIP_BODY;
+        } catch (IOException ex) {
+            throw new JspTagException(ex.toString());
+        }
+    }
+}
+
+    
+        
+    

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/LogTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ShowSource.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ShowSource.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ShowSource.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ShowSource.java Mon May 29 04:51:34 2006
@@ -0,0 +1,72 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package examples;
+
+
+import javax.servlet.*;
+import javax.servlet.jsp.*;
+import javax.servlet.jsp.tagext.*;
+
+import java.io.*;
+
+/**
+ * Display the sources of the JSP file.
+ */
+public class ShowSource
+    extends TagSupport
+{
+    String jspFile;
+    
+    public void setJspFile(String jspFile) {
+        this.jspFile = jspFile;
+    }
+
+    public int doEndTag() throws JspException {
+	if ((jspFile.indexOf( ".." ) >= 0) ||
+            (jspFile.toUpperCase().indexOf("/WEB-INF/") != 0) ||
+            (jspFile.toUpperCase().indexOf("/META-INF/") != 0))
+	    throw new JspTagException("Invalid JSP file " + jspFile);
+
+        InputStream in
+            = pageContext.getServletContext().getResourceAsStream(jspFile);
+
+        if (in == null)
+            throw new JspTagException("Unable to find JSP file: "+jspFile);
+
+        InputStreamReader reader = new InputStreamReader(in);
+	JspWriter out = pageContext.getOut();
+
+
+        try {
+            out.println("<body>");
+            out.println("<pre>");
+            for(int ch = in.read(); ch != -1; ch = in.read())
+                if (ch == '<')
+                    out.print("&lt;");
+                else
+                    out.print((char) ch);
+            out.println("</pre>");
+            out.println("</body>");
+        } catch (IOException ex) {
+            throw new JspTagException("IOException: "+ex.toString());
+        }
+        return super.doEndTag();
+    }
+}
+
+    
+        
+    

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/examples/ShowSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/ExampleFilter.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/ExampleFilter.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/ExampleFilter.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/ExampleFilter.java Mon May 29 04:51:34 2006
@@ -0,0 +1,139 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package filters;
+
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+
+/**
+ * Example filter that can be attached to either an individual servlet
+ * or to a URL pattern.  This filter performs the following functions:
+ * <ul>
+ * <li>Attaches itself as a request attribute, under the attribute name
+ *     defined by the value of the <code>attribute</code> initialization
+ *     parameter.</li>
+ * <li>Calculates the number of milliseconds required to perform the
+ *     servlet processing required by this request, including any
+ *     subsequently defined filters, and logs the result to the servlet
+ *     context log for this application.
+ * </ul>
+ *
+ * @author Craig McClanahan
+ * @version $Revision: 267129 $ $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public final class ExampleFilter implements Filter {
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * The request attribute name under which we store a reference to ourself.
+     */
+    private String attribute = null;
+
+
+    /**
+     * The filter configuration object we are associated with.  If this value
+     * is null, this filter instance is not currently configured.
+     */
+    private FilterConfig filterConfig = null;
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Take this filter out of service.
+     */
+    public void destroy() {
+
+        this.attribute = null;
+        this.filterConfig = null;
+
+    }
+
+
+    /**
+     * Time the processing that is performed by all subsequent filters in the
+     * current filter stack, including the ultimately invoked servlet.
+     *
+     * @param request The servlet request we are processing
+     * @param result The servlet response we are creating
+     * @param chain The filter chain we are processing
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception ServletException if a servlet error occurs
+     */
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain)
+	throws IOException, ServletException {
+
+	// Store ourselves as a request attribute (if requested)
+	if (attribute != null)
+	    request.setAttribute(attribute, this);
+
+	// Time and log the subsequent processing
+	long startTime = System.currentTimeMillis();
+        chain.doFilter(request, response);
+	long stopTime = System.currentTimeMillis();
+	filterConfig.getServletContext().log
+	    (this.toString() + ": " + (stopTime - startTime) +
+	     " milliseconds");
+
+    }
+
+
+    /**
+     * Place this filter into service.
+     *
+     * @param filterConfig The filter configuration object
+     */
+    public void init(FilterConfig filterConfig) throws ServletException {
+
+	this.filterConfig = filterConfig;
+        this.attribute = filterConfig.getInitParameter("attribute");
+
+    }
+
+
+    /**
+     * Return a String representation of this object.
+     */
+    public String toString() {
+
+	if (filterConfig == null)
+	    return ("InvokerFilter()");
+	StringBuffer sb = new StringBuffer("InvokerFilter(");
+	sb.append(filterConfig);
+	sb.append(")");
+	return (sb.toString());
+
+    }
+
+
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/ExampleFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/RequestDumperFilter.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/RequestDumperFilter.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/RequestDumperFilter.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/RequestDumperFilter.java Mon May 29 04:51:34 2006
@@ -0,0 +1,200 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package filters;
+
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.sql.Timestamp;
+import java.util.Enumeration;
+import java.util.Locale;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * Example filter that dumps interesting state information about a request
+ * to the associated servlet context log file, before allowing the servlet
+ * to process the request in the usual way.  This can be installed as needed
+ * to assist in debugging problems.
+ *
+ * @author Craig McClanahan
+ * @version $Revision: 267129 $ $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public final class RequestDumperFilter implements Filter {
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * The filter configuration object we are associated with.  If this value
+     * is null, this filter instance is not currently configured.
+     */
+    private FilterConfig filterConfig = null;
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Take this filter out of service.
+     */
+    public void destroy() {
+
+        this.filterConfig = null;
+
+    }
+
+
+    /**
+     * Time the processing that is performed by all subsequent filters in the
+     * current filter stack, including the ultimately invoked servlet.
+     *
+     * @param request The servlet request we are processing
+     * @param result The servlet response we are creating
+     * @param chain The filter chain we are processing
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception ServletException if a servlet error occurs
+     */
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain)
+	throws IOException, ServletException {
+
+        if (filterConfig == null)
+	    return;
+
+	// Render the generic servlet request properties
+	StringWriter sw = new StringWriter();
+	PrintWriter writer = new PrintWriter(sw);
+	writer.println("Request Received at " +
+		       (new Timestamp(System.currentTimeMillis())));
+	writer.println(" characterEncoding=" + request.getCharacterEncoding());
+	writer.println("     contentLength=" + request.getContentLength());
+	writer.println("       contentType=" + request.getContentType());
+	writer.println("            locale=" + request.getLocale());
+	writer.print("           locales=");
+	Enumeration locales = request.getLocales();
+	boolean first = true;
+	while (locales.hasMoreElements()) {
+	    Locale locale = (Locale) locales.nextElement();
+	    if (first)
+	        first = false;
+	    else
+	        writer.print(", ");
+	    writer.print(locale.toString());
+	}
+	writer.println();
+	Enumeration names = request.getParameterNames();
+	while (names.hasMoreElements()) {
+	    String name = (String) names.nextElement();
+	    writer.print("         parameter=" + name + "=");
+	    String values[] = request.getParameterValues(name);
+	    for (int i = 0; i < values.length; i++) {
+	        if (i > 0)
+		    writer.print(", ");
+		writer.print(values[i]);
+	    }
+	    writer.println();
+	}
+	writer.println("          protocol=" + request.getProtocol());
+	writer.println("        remoteAddr=" + request.getRemoteAddr());
+	writer.println("        remoteHost=" + request.getRemoteHost());
+	writer.println("            scheme=" + request.getScheme());
+	writer.println("        serverName=" + request.getServerName());
+	writer.println("        serverPort=" + request.getServerPort());
+	writer.println("          isSecure=" + request.isSecure());
+
+	// Render the HTTP servlet request properties
+	if (request instanceof HttpServletRequest) {
+	    writer.println("---------------------------------------------");
+	    HttpServletRequest hrequest = (HttpServletRequest) request;
+	    writer.println("       contextPath=" + hrequest.getContextPath());
+	    Cookie cookies[] = hrequest.getCookies();
+            if (cookies == null)
+                cookies = new Cookie[0];
+	    for (int i = 0; i < cookies.length; i++) {
+	        writer.println("            cookie=" + cookies[i].getName() +
+			       "=" + cookies[i].getValue());
+	    }
+	    names = hrequest.getHeaderNames();
+	    while (names.hasMoreElements()) {
+	        String name = (String) names.nextElement();
+		String value = hrequest.getHeader(name);
+	        writer.println("            header=" + name + "=" + value);
+	    }
+	    writer.println("            method=" + hrequest.getMethod());
+	    writer.println("          pathInfo=" + hrequest.getPathInfo());
+	    writer.println("       queryString=" + hrequest.getQueryString());
+	    writer.println("        remoteUser=" + hrequest.getRemoteUser());
+	    writer.println("requestedSessionId=" +
+			   hrequest.getRequestedSessionId());
+	    writer.println("        requestURI=" + hrequest.getRequestURI());
+	    writer.println("       servletPath=" + hrequest.getServletPath());
+	}
+	writer.println("=============================================");
+
+	// Log the resulting string
+	writer.flush();
+	filterConfig.getServletContext().log(sw.getBuffer().toString());
+
+	// Pass control on to the next filter
+        chain.doFilter(request, response);
+
+    }
+
+
+    /**
+     * Place this filter into service.
+     *
+     * @param filterConfig The filter configuration object
+     */
+    public void init(FilterConfig filterConfig) throws ServletException {
+
+	this.filterConfig = filterConfig;
+
+    }
+
+
+    /**
+     * Return a String representation of this object.
+     */
+    public String toString() {
+
+	if (filterConfig == null)
+	    return ("RequestDumperFilter()");
+	StringBuffer sb = new StringBuffer("RequestDumperFilter(");
+	sb.append(filterConfig);
+	sb.append(")");
+	return (sb.toString());
+
+    }
+
+
+}
+

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/RequestDumperFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.java Mon May 29 04:51:34 2006
@@ -0,0 +1,171 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package filters;
+
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.UnavailableException;
+
+
+/**
+ * <p>Example filter that sets the character encoding to be used in parsing the
+ * incoming request, either unconditionally or only if the client did not
+ * specify a character encoding.  Configuration of this filter is based on
+ * the following initialization parameters:</p>
+ * <ul>
+ * <li><strong>encoding</strong> - The character encoding to be configured
+ *     for this request, either conditionally or unconditionally based on
+ *     the <code>ignore</code> initialization parameter.  This parameter
+ *     is required, so there is no default.</li>
+ * <li><strong>ignore</strong> - If set to "true", any character encoding
+ *     specified by the client is ignored, and the value returned by the
+ *     <code>selectEncoding()</code> method is set.  If set to "false,
+ *     <code>selectEncoding()</code> is called <strong>only</strong> if the
+ *     client has not already specified an encoding.  By default, this
+ *     parameter is set to "true".</li>
+ * </ul>
+ *
+ * <p>Although this filter can be used unchanged, it is also easy to
+ * subclass it and make the <code>selectEncoding()</code> method more
+ * intelligent about what encoding to choose, based on characteristics of
+ * the incoming request (such as the values of the <code>Accept-Language</code>
+ * and <code>User-Agent</code> headers, or a value stashed in the current
+ * user's session.</p>
+ *
+ * @author Craig McClanahan
+ * @version $Revision: 267129 $ $Date: 2004-03-18 17:40:35 +0100 (jeu., 18 mars 2004) $
+ */
+
+public class SetCharacterEncodingFilter implements Filter {
+
+
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * The default character encoding to set for requests that pass through
+     * this filter.
+     */
+    protected String encoding = null;
+
+
+    /**
+     * The filter configuration object we are associated with.  If this value
+     * is null, this filter instance is not currently configured.
+     */
+    protected FilterConfig filterConfig = null;
+
+
+    /**
+     * Should a character encoding specified by the client be ignored?
+     */
+    protected boolean ignore = true;
+
+
+    // --------------------------------------------------------- Public Methods
+
+
+    /**
+     * Take this filter out of service.
+     */
+    public void destroy() {
+
+        this.encoding = null;
+        this.filterConfig = null;
+
+    }
+
+
+    /**
+     * Select and set (if specified) the character encoding to be used to
+     * interpret request parameters for this request.
+     *
+     * @param request The servlet request we are processing
+     * @param result The servlet response we are creating
+     * @param chain The filter chain we are processing
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception ServletException if a servlet error occurs
+     */
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain)
+	throws IOException, ServletException {
+
+        // Conditionally select and set the character encoding to be used
+        if (ignore || (request.getCharacterEncoding() == null)) {
+            String encoding = selectEncoding(request);
+            if (encoding != null)
+                request.setCharacterEncoding(encoding);
+        }
+
+	// Pass control on to the next filter
+        chain.doFilter(request, response);
+
+    }
+
+
+    /**
+     * Place this filter into service.
+     *
+     * @param filterConfig The filter configuration object
+     */
+    public void init(FilterConfig filterConfig) throws ServletException {
+
+	this.filterConfig = filterConfig;
+        this.encoding = filterConfig.getInitParameter("encoding");
+        String value = filterConfig.getInitParameter("ignore");
+        if (value == null)
+            this.ignore = true;
+        else if (value.equalsIgnoreCase("true"))
+            this.ignore = true;
+        else if (value.equalsIgnoreCase("yes"))
+            this.ignore = true;
+        else
+            this.ignore = false;
+
+    }
+
+
+    // ------------------------------------------------------ Protected Methods
+
+
+    /**
+     * Select an appropriate character encoding to be used, based on the
+     * characteristics of the current request and/or filter initialization
+     * parameters.  If no character encoding should be set, return
+     * <code>null</code>.
+     * <p>
+     * The default implementation unconditionally returns the value configured
+     * by the <strong>encoding</strong> initialization parameter for this
+     * filter.
+     *
+     * @param request The servlet request we are processing
+     */
+    protected String selectEncoding(ServletRequest request) {
+
+        return (this.encoding);
+
+    }
+
+
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/filters/SetCharacterEncodingFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/BookBean.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/BookBean.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/BookBean.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/BookBean.java Mon May 29 04:51:34 2006
@@ -0,0 +1,43 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples;
+
+public class BookBean {
+    private String title;
+    private String author;
+    private String isbn;
+    
+    public BookBean( String title, String author, String isbn ) {
+        this.title = title;
+        this.author = author;
+        this.isbn = isbn;
+    }
+
+    public String getTitle() {
+        return this.title;
+    }
+    
+    public String getAuthor() {
+        return this.author;
+    }
+    
+    public String getIsbn() {
+        return this.isbn;
+    }
+    
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/BookBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/FooBean.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/FooBean.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/FooBean.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/FooBean.java Mon May 29 04:51:34 2006
@@ -0,0 +1,35 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples;
+
+public class FooBean {
+    private String bar;
+    
+    public FooBean() {
+        bar = "Initial value";
+    }
+    
+    public String getBar() {
+        return this.bar;
+    }
+    
+    public void setBar(String bar) {
+        this.bar = bar;
+    }
+    
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/FooBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java Mon May 29 04:51:34 2006
@@ -0,0 +1,44 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package jsp2.examples.el;
+
+import java.util.*;
+
+/**
+ * Defines the functions for the jsp2 example tag library.
+ * 
+ * <p>Each function is defined as a static method.</p>
+ */
+public class Functions {
+    public static String reverse( String text ) {
+        return new StringBuffer( text ).reverse().toString();
+    }
+
+    public static int numVowels( String text ) {
+        String vowels = "aeiouAEIOU";
+	int result = 0;
+        for( int i = 0; i < text.length(); i++ ) {
+	    if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
+	        result++;
+	    }
+	}
+	return result;
+    }
+
+    public static String caps( String text ) {
+        return text.toUpperCase();
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/el/Functions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,54 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import javax.servlet.jsp.tagext.DynamicAttributes;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.io.IOException;
+
+/**
+ * SimpleTag handler that echoes all its attributes 
+ */
+public class EchoAttributesTag 
+    extends SimpleTagSupport
+    implements DynamicAttributes
+{
+    private ArrayList keys = new ArrayList();
+    private ArrayList values = new ArrayList();
+
+    public void doTag() throws JspException, IOException {
+	JspWriter out = getJspContext().getOut();
+	for( int i = 0; i < keys.size(); i++ ) {
+	    String key = (String)keys.get( i );
+	    Object value = values.get( i );
+	    out.println( "<li>" + key + " = " + value + "</li>" );
+        }
+    }
+
+    public void setDynamicAttribute( String uri, String localName, 
+	Object value ) 
+	throws JspException
+    {
+	keys.add( localName );
+	values.add( value );
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/EchoAttributesTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,44 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.util.HashMap;
+import jsp2.examples.BookBean;
+
+/**
+ * SimpleTag handler that pretends to search for a book, and stores
+ * the result in a scoped variable.
+ */
+public class FindBookSimpleTag extends SimpleTagSupport {
+    private String var;
+    
+    private static final String BOOK_TITLE = "The Lord of the Rings";
+    private static final String BOOK_AUTHOR = "J. R. R. Tolkein";
+    private static final String BOOK_ISBN = "0618002251";
+
+    public void doTag() throws JspException {
+        BookBean book = new BookBean( BOOK_TITLE, BOOK_AUTHOR, BOOK_ISBN );
+        getJspContext().setAttribute( this.var, book );
+    }
+
+    public void setVar( String var ) {
+	this.var = var;
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/FindBookSimpleTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,31 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.io.IOException;
+
+/**
+ * SimpleTag handler that prints "Hello, world!"
+ */
+public class HelloWorldSimpleTag extends SimpleTagSupport {
+    public void doTag() throws JspException, IOException {
+	getJspContext().getOut().write( "Hello, world!" );
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/HelloWorldSimpleTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,42 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.util.HashMap;
+import java.io.IOException;
+
+/**
+ * SimpleTag handler that accepts a num attribute and 
+ * invokes its body 'num' times.
+ */
+public class RepeatSimpleTag extends SimpleTagSupport {
+    private int num;
+
+    public void doTag() throws JspException, IOException {
+        for (int i=0; i<num; i++) {
+            getJspContext().setAttribute("count", String.valueOf( i + 1 ) );
+	    getJspBody().invoke(null);
+        }
+    }
+
+    public void setNum(int num) {
+	this.num = num;
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/RepeatSimpleTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/ShuffleSimpleTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/ShuffleSimpleTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/ShuffleSimpleTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/ShuffleSimpleTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,81 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.JspFragment;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.util.HashMap;
+import java.io.IOException;
+
+/**
+ * SimpleTag handler that accepts takes three attributes of type
+ * JspFragment and invokes then in a random order.
+ */
+public class ShuffleSimpleTag extends SimpleTagSupport {
+    private JspFragment fragment1;
+    private JspFragment fragment2;
+    private JspFragment fragment3;
+
+    public void doTag() throws JspException, IOException {
+        switch( (int)(Math.random() * 6) ) {
+            case 0:
+                fragment1.invoke( null );
+                fragment2.invoke( null );
+                fragment3.invoke( null );
+                break;
+            case 1:
+                fragment1.invoke( null );
+                fragment3.invoke( null );
+                fragment2.invoke( null );
+                break;
+            case 2:
+                fragment2.invoke( null );
+                fragment1.invoke( null );
+                fragment3.invoke( null );
+                break;
+            case 3:
+                fragment2.invoke( null );
+                fragment3.invoke( null );
+                fragment1.invoke( null );
+                break;
+            case 4:
+                fragment3.invoke( null );
+                fragment1.invoke( null );
+                fragment2.invoke( null );
+                break;
+            case 5:
+                fragment3.invoke( null );
+                fragment2.invoke( null );
+                fragment1.invoke( null );
+                break;
+        }
+    }
+
+    public void setFragment1( JspFragment fragment1 ) {
+        this.fragment1 = fragment1;
+    }
+    
+    public void setFragment2( JspFragment fragment2 ) {
+        this.fragment2 = fragment2;
+    }
+    
+    public void setFragment3( JspFragment fragment3 ) {
+        this.fragment3 = fragment3;
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/ShuffleSimpleTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java?rev=410080&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java (added)
+++ tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java Mon May 29 04:51:34 2006
@@ -0,0 +1,46 @@
+/*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+package jsp2.examples.simpletag;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * Displays a tile as a single cell in a table.
+ */
+public class TileSimpleTag extends SimpleTagSupport {
+    private String color;
+    private String label;
+
+    public void doTag() throws JspException, IOException {
+	getJspContext().getOut().write( 
+	    "<td width=\"32\" height=\"32\" bgcolor=\"" + this.color + 
+	    "\"><font color=\"#ffffff\"><center>" + this.label + 
+                "</center></font></td>" );
+    }
+
+    public void setColor( String color ) {
+        this.color = color;
+    }
+    
+    public void setLabel( String label ) {
+        this.label = label;
+    }
+}

Propchange: tomcat/tc6.0.x/trunk/webapps/examples/WEB-INF/classes/jsp2/examples/simpletag/TileSimpleTag.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org