kinman 01/12/05 10:41:47 Modified: jasper/src/share/org/apache/jasper Tag: tomcat_40_branch Constants.java jasper/src/share/org/apache/jasper/compiler Tag: tomcat_40_branch IncludeGenerator.java jasper/src/share/org/apache/jasper/runtime Tag: tomcat_40_branch BodyContentImpl.java JspRuntimeLibrary.java JspWriterImpl.java PageContextImpl.java Log: -- Back-ported fixes from the head branch. Revision Changes Path No revision No revision 1.13.2.1 +1 -0 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/Constants.java,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -r1.13 -r1.13.2.1 --- Constants.java 2001/07/23 19:57:32 1.13 +++ Constants.java 2001/12/05 18:41:46 1.13.2.1 @@ -149,6 +149,7 @@ public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri"; public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path"; public static final String TMP_DIR = "javax.servlet.context.tempdir"; + public static final String FORWARD_SEEN = "javax.servlet.forward.seen"; /** * Public Id and the Resource path (of the cached copy) No revision No revision 1.8.2.1 +10 -3 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/IncludeGenerator.java Index: IncludeGenerator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -r1.8 -r1.8.2.1 --- IncludeGenerator.java 2001/08/14 23:28:55 1.8 +++ IncludeGenerator.java 2001/12/05 18:41:46 1.8.2.1 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v 1.8 2001/08/14 23:28:55 craigmcc Exp $ - * $Revision: 1.8 $ - * $Date: 2001/08/14 23:28:55 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/IncludeGenerator.java,v 1.8.2.1 2001/12/05 18:41:46 kinman Exp $ + * $Revision: 1.8.2.1 $ + * $Date: 2001/12/05 18:41:46 $ * * ==================================================================== * @@ -186,6 +186,13 @@ writer.println("JspRuntimeLibrary.include(request, response, " + JspUtil.getExpr(page, isXml) + " + _jspx_qStr, " + "out, " + flush + ");"); + + // If there is a forward in the include chain, quit. + writer.println("if (\"true\".equals(request.getAttribute(\"" + + Constants.FORWARD_SEEN + "\")))"); + writer.pushIndent(); + writer.println("return;"); + writer.popIndent(); writer.popIndent(); writer.println("}"); No revision No revision 1.2.2.1 +12 -12 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/BodyContentImpl.java Index: BodyContentImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/BodyContentImpl.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- BodyContentImpl.java 2001/03/12 22:17:33 1.2 +++ BodyContentImpl.java 2001/12/05 18:41:46 1.2.2.1 @@ -82,19 +82,25 @@ protected int bufferSize = Constants.DEFAULT_BUFFER_SIZE; private int nextChar; static String lineSeparator = System.getProperty("line.separator"); + private boolean closed = false; - public BodyContentImpl (JspWriter writer) { super(writer); cb = new char[bufferSize]; nextChar = 0; } + private void ensureOpen() throws IOException { + if (closed) + throw new IOException("Stream closed"); + } + /** * Write a single character. * */ public void write(int c) throws IOException { + ensureOpen(); synchronized (lock) { if (nextChar >= bufferSize) { reAllocBuff (0); @@ -141,6 +147,7 @@ public void write(char cbuf[], int off, int len) throws IOException { + ensureOpen(); synchronized (lock) { if ((off < 0) || (off > cbuf.length) || (len < 0) || @@ -175,6 +182,7 @@ * */ public void write(String s, int off, int len) throws IOException { + ensureOpen(); synchronized (lock) { if (len >= bufferSize - nextChar) reAllocBuff(len); @@ -202,9 +210,7 @@ */ public void newLine() throws IOException { - synchronized (lock) { - write(lineSeparator); - } + write(lineSeparator); } /** @@ -244,7 +250,6 @@ * method. * * @param i The <code>int</code> to be printed - * @see java.lang.Integer#toString(int) * @throws java.io.IOException */ @@ -260,7 +265,6 @@ * method. * * @param l The <code>long</code> to be printed - * @see java.lang.Long#toString(long) * @throws java.io.IOException */ @@ -276,7 +280,6 @@ * method. * * @param f The <code>float</code> to be printed - * @see java.lang.Float#toString(float) * @throws java.io.IOException */ @@ -292,7 +295,6 @@ * #write(int)}</code> method. * * @param d The <code>double</code> to be printed - * @see java.lang.Double#toString(double) * @throws java.io.IOException */ @@ -342,7 +344,6 @@ * method. * * @param obj The <code>Object</code> to be printed - * @see java.lang.Object#toString() * @throws java.io.IOException */ @@ -525,9 +526,8 @@ */ public void close() throws IOException { - synchronized (lock) { - cb = null; - } + cb = null; + closed = true; } /** 1.8.2.1 +5 -5 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java Index: JspRuntimeLibrary.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -r1.8 -r1.8.2.1 --- JspRuntimeLibrary.java 2001/08/14 23:28:55 1.8 +++ JspRuntimeLibrary.java 2001/12/05 18:41:46 1.8.2.1 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v 1.8 2001/08/14 23:28:55 craigmcc Exp $ - * $Revision: 1.8 $ - * $Date: 2001/08/14 23:28:55 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v 1.8.2.1 2001/12/05 18:41:46 kinman Exp $ + * $Revision: 1.8.2.1 $ + * $Date: 2001/12/05 18:41:46 $ * * ==================================================================== * @@ -89,6 +89,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.BodyContent; import org.apache.jasper.JasperException; import org.apache.jasper.Constants; @@ -803,7 +804,7 @@ boolean flush) throws IOException, ServletException { - if (flush) + if (flush && !(out instanceof BodyContent)) out.flush(); // FIXME - It is tempting to use request.getRequestDispatcher() to @@ -819,6 +820,5 @@ new ServletResponseWrapperInclude(response, out)); } - } 1.1.4.1 +10 -13 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspWriterImpl.java Index: JspWriterImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -r1.1 -r1.1.4.1 --- JspWriterImpl.java 2000/08/12 00:52:12 1.1 +++ JspWriterImpl.java 2001/12/05 18:41:46 1.1.4.1 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v 1.1 2000/08/12 00:52:12 pierred Exp $ - * $Revision: 1.1 $ - * $Date: 2000/08/12 00:52:12 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspWriterImpl.java,v 1.1.4.1 2001/12/05 18:41:46 kinman Exp $ + * $Revision: 1.1.4.1 $ + * $Date: 2001/12/05 18:41:46 $ * * ==================================================================== * @@ -88,7 +88,6 @@ */ public class JspWriterImpl extends JspWriter { - protected Writer out; protected ServletResponse response; @@ -99,7 +98,8 @@ protected static int defaultCharBufferSize = Constants.DEFAULT_BUFFER_SIZE; protected boolean flushed = false; - + protected boolean closed = false; + public JspWriterImpl() { super( defaultCharBufferSize, true ); } @@ -155,7 +155,7 @@ ensureOpen(); if (nextChar == 0) return; - initOut(); + initOut(); out.write(cb, 0, nextChar); nextChar = 0; } @@ -217,12 +217,14 @@ */ public void close() throws IOException { synchronized (lock) { - if (response == null) + if (response == null || closed) + // multiple calls to close is OK return; flush(); if (out != null) out.close(); out = null; + closed = true; // cb = null; } } @@ -236,7 +238,7 @@ /** check to make sure that the stream has not been closed */ protected void ensureOpen() throws IOException { - if (response == null) + if (response == null || closed) throw new IOException("Stream closed"); } @@ -434,7 +436,6 @@ * method. * * @param i The <code>int</code> to be printed - * @see java.lang.Integer#toString(int) */ public void print(int i) throws IOException { write(String.valueOf(i)); @@ -448,7 +449,6 @@ * method. * * @param l The <code>long</code> to be printed - * @see java.lang.Long#toString(long) */ public void print(long l) throws IOException { write(String.valueOf(l)); @@ -462,7 +462,6 @@ * method. * * @param f The <code>float</code> to be printed - * @see java.lang.Float#toString(float) */ public void print(float f) throws IOException { write(String.valueOf(f)); @@ -476,7 +475,6 @@ * #write(int)}</code> method. * * @param d The <code>double</code> to be printed - * @see java.lang.Double#toString(double) */ public void print(double d) throws IOException { write(String.valueOf(d)); @@ -520,7 +518,6 @@ * method. * * @param obj The <code>Object</code> to be printed - * @see java.lang.Object#toString() */ public void print(Object obj) throws IOException { write(String.valueOf(obj)); 1.13.2.1 +9 -4 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java Index: PageContextImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v retrieving revision 1.13 retrieving revision 1.13.2.1 diff -u -r1.13 -r1.13.2.1 --- PageContextImpl.java 2001/08/14 23:28:55 1.13 +++ PageContextImpl.java 2001/12/05 18:41:46 1.13.2.1 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v 1.13 2001/08/14 23:28:55 craigmcc Exp $ - * $Revision: 1.13 $ - * $Date: 2001/08/14 23:28:55 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/PageContextImpl.java,v 1.13.2.1 2001/12/05 18:41:46 kinman Exp $ + * $Revision: 1.13.2.1 $ + * $Date: 2001/12/05 18:41:46 $ * * ==================================================================== * @@ -79,8 +79,8 @@ import javax.servlet.http.HttpSession; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; - import javax.servlet.jsp.PageContext; import javax.servlet.jsp.JspFactory; import javax.servlet.jsp.JspWriter; @@ -400,6 +400,10 @@ public void forward(String relativeUrlPath) throws ServletException, IOException { + // Make sure that the response object is not the wrapper for include + while (response instanceof HttpServletResponseWrapper) + response = ((HttpServletResponseWrapper)response).getResponse(); + String path = getAbsolutePathRelativeToContext(relativeUrlPath); String includeUri = (String) request.getAttribute(Constants.INC_SERVLET_PATH); @@ -410,6 +414,7 @@ } finally { if (includeUri != null) request.setAttribute(Constants.INC_SERVLET_PATH, includeUri); + request.setAttribute(Constants.FORWARD_SEEN, "true"); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>