costin 99/11/03 15:43:58 Modified: src/share/javax/servlet/jsp/tagext BodyTag.java BodyTagSupport.java TagAttributeInfo.java TagSupport.java src/share/org/apache/jasper Constants.java src/share/org/apache/jasper/compiler Compiler.java JspReader.java Parser.java SetPropertyGenerator.java TagBeginGenerator.java TagEndGenerator.java TagLibraries.java TagLibraryInfoImpl.java src/share/org/apache/jasper/resources messages.properties src/share/org/apache/jasper/runtime BodyContentImpl.java JspServlet.java src/share/org/apache/tomcat/core ServletLoader.java Log: Merged fixes from J2EE branch. Packages: javax.servlet.jsp.tagext org.apache.jasper.* Revision Changes Path 1.3 +4 -9 jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTag.java Index: BodyTag.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BodyTag.java 1999/10/20 11:37:21 1.2 +++ BodyTag.java 1999/11/03 23:42:33 1.3 @@ -1,9 +1,5 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTag.java,v 1.2 1999/10/20 11:37:21 akv Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/20 11:37:21 $ - * - * ==================================================================== + * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTag.java,v 1.3 1999/11/03 23:42:33 costin Exp $ $Date: 1999/11/03 23:42:33 $ $Revision: 1.3 $ * * The Apache Software License, Version 1.1 * @@ -57,8 +53,7 @@ * information on the Apache Software Foundation, please see * . * - */ - + */ package javax.servlet.jsp.tagext; import javax.servlet.jsp.*; @@ -132,7 +127,7 @@ * @seealso #doAfterBody */ - void doInitBody() throws JspError; + void doInitBody() throws JspException; /** * Actions after some body has been evaluated. @@ -151,5 +146,5 @@ * @seealso #doInitBody */ - int doAfterBody() throws JspError; + int doAfterBody() throws JspException; } 1.3 +21 -9 jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTagSupport.java Index: BodyTagSupport.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTagSupport.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BodyTagSupport.java 1999/10/20 11:40:29 1.2 +++ BodyTagSupport.java 1999/11/03 23:42:36 1.3 @@ -1,9 +1,5 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTagSupport.java,v 1.2 1999/10/20 11:40:29 akv Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/20 11:40:29 $ - * - * ==================================================================== + * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/BodyTagSupport.java,v 1.3 1999/11/03 23:42:36 costin Exp $ $Date: 1999/11/03 23:42:36 $ $Revision: 1.3 $ * * The Apache Software License, Version 1.1 * @@ -57,8 +53,7 @@ * information on the Apache Software Foundation, please see * . * - */ - + */ package javax.servlet.jsp.tagext; import javax.servlet.jsp.*; @@ -91,6 +86,23 @@ } /** + * Process the start tag for this instance. + * + * The doStartTag() method assumes that all setter methods have been + * invoked before. + * + * When this method is invoked, the body has not yet been invoked. + * + * @returns EVAL_BODY_TAG if the tag wants to process body, SKIP_BODY if it + * does ont want to process it. + */ + + public int doStartTag() throws JspException { + return EVAL_BODY_TAG; + } + + + /** * Process the end tag. This method will be called on all Tag objects. * * All instance state associated with this instance must be reset. @@ -129,7 +141,7 @@ * @seealso #doAfterBody */ - public void doInitBody() { + public void doInitBody() throws JspException { } /** @@ -149,7 +161,7 @@ * @seealso #doInitBody */ - public int doAfterBody() throws JspError { + public int doAfterBody() throws JspException { return SKIP_BODY; } 1.5 +5 -8 jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagAttributeInfo.java Index: TagAttributeInfo.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagAttributeInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TagAttributeInfo.java 1999/10/20 21:36:16 1.4 +++ TagAttributeInfo.java 1999/11/03 23:42:37 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagAttributeInfo.java,v 1.4 1999/10/20 21:36:16 akv Exp $ - * $Revision: 1.4 $ - * $Date: 1999/10/20 21:36:16 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagAttributeInfo.java,v 1.5 1999/11/03 23:42:37 costin Exp $ + * $Revision: 1.5 $ + * $Date: 1999/11/03 23:42:37 $ * * ==================================================================== * @@ -90,13 +90,12 @@ // TODO -- add the content descriptor... public TagAttributeInfo(String name, boolean required, boolean rtexprvalue, - String type, boolean reqTime) + String type) { this.name = name; this.required = required; this.rtexprvalue = rtexprvalue; this.type = type; - this.reqTime = reqTime; } /** @@ -120,7 +119,7 @@ */ public boolean canBeRequestTime() { - return reqTime; + return rtexprvalue; } /** @@ -147,7 +146,6 @@ StringBuffer b = new StringBuffer(); b.append("name = "+name+" "); b.append("type = "+type+" "); - b.append("reqTime = "+reqTime+" "); b.append("required = "+required+" "); b.append("rtexprvalue = "+rtexprvalue+" "); return b.toString(); @@ -159,7 +157,6 @@ private String name; private String type; - private boolean reqTime; private boolean required; private boolean rtexprvalue; } 1.3 +6 -11 jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagSupport.java Index: TagSupport.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagSupport.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TagSupport.java 1999/10/20 21:36:19 1.2 +++ TagSupport.java 1999/11/03 23:42:40 1.3 @@ -1,9 +1,5 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagSupport.java,v 1.2 1999/10/20 21:36:19 akv Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/20 21:36:19 $ - * - * ==================================================================== + * $Header: /home/cvs/jakarta-tomcat/src/share/javax/servlet/jsp/tagext/TagSupport.java,v 1.3 1999/11/03 23:42:40 costin Exp $ $Date: 1999/11/03 23:42:40 $ $Revision: 1.3 $ * * The Apache Software License, Version 1.1 * @@ -57,8 +53,7 @@ * information on the Apache Software Foundation, please see * . * - */ - + */ package javax.servlet.jsp.tagext; import javax.servlet.jsp.*; @@ -106,7 +101,7 @@ } if ((isInterface && klass.isInstance(tag)) || - klass.equals(tag.getClass())) + klass.isAssignableFrom(tag.getClass())) return tag; else from = tag; @@ -145,7 +140,7 @@ * * When this method is invoked, the body has not yet been invoked. * - * @returns EVAL_BODY if the tag wants to process body, SKIP_BODY if it + * @returns EVAL_BODY_INCLUDE if the tag wants to process body, SKIP_BODY if it * does ont want to process it. */ @@ -197,7 +192,7 @@ * Set the id attribute */ - public void setTagId(String id) { + public void setId(String id) { this.id = id; } @@ -207,7 +202,7 @@ * @return the value of the id attribute, or null */ - public String getTagId() { + public String getId() { return id; } 1.7 +11 -3 jakarta-tomcat/src/share/org/apache/jasper/Constants.java Index: Constants.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/Constants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Constants.java 1999/10/21 02:47:50 1.6 +++ Constants.java 1999/11/03 23:42:55 1.7 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/Constants.java,v 1.6 1999/10/21 02:47:50 mandar Exp $ - * $Revision: 1.6 $ - * $Date: 1999/10/21 02:47:50 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/Constants.java,v 1.7 1999/11/03 23:42:55 costin Exp $ + * $Revision: 1.7 $ + * $Date: 1999/11/03 23:42:55 $ * * ==================================================================== * @@ -112,6 +112,14 @@ * want to have this JSP engine running on them. */ public static final String SERVLET_CLASSPATH = "org.apache.tomcat.jsp_classpath"; + + /** + * ServletContext attribute for classpath. This is tomcat specific. + * Other servlet engines can choose to have this attribute if they + * want to have this JSP engine running on them. + */ + public static final String SERVLET_CLASS_LOADER = "org.apache.tomcat.classloader"; + /** * Codes that indicate how verbose you want the JSP engine to be. 1.3 +4 -4 jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java Index: Compiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Compiler.java 1999/10/15 00:11:07 1.2 +++ Compiler.java 1999/11/03 23:43:02 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.2 1999/10/15 00:11:07 akv Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/15 00:11:07 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Compiler.java,v 1.3 1999/11/03 23:43:02 costin Exp $ + * $Revision: 1.3 $ + * $Date: 1999/11/03 23:43:02 $ * * ==================================================================== * @@ -118,7 +118,7 @@ Constants.message("jsp.message.class_file_name_is", new Object[] { classFileName }, Constants.MED_VERBOSITY); - + JspReader reader = JspReader.createJspReader(ctxt.getJspFile(), ctxt.getServletContext()); ServletWriter writer = 1.2 +4 -4 jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java Index: JspReader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JspReader.java 1999/10/09 00:20:36 1.1 +++ JspReader.java 1999/11/03 23:43:06 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v 1.1 1999/10/09 00:20:36 duncan Exp $ - * $Revision: 1.1 $ - * $Date: 1999/10/09 00:20:36 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/JspReader.java,v 1.2 1999/11/03 23:43:06 costin Exp $ + * $Revision: 1.2 $ + * $Date: 1999/11/03 23:43:06 $ * * ==================================================================== * @@ -664,7 +664,7 @@ if ( ! isSpace() ) { int ch = peekChar(); // Look for a single-char work delimiter: - if ( ch == '=' || ch == '>' || ch == '"' || ch == '\'' ) + if ( ch == '=' || ch == '>' || ch == '"' || ch == '\'' || ch == '/') return true; // Look for an end-of-comment or end-of-tag: if ( ch == '-' ) { 1.5 +55 -37 jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Parser.java 1999/10/21 07:56:40 1.4 +++ Parser.java 1999/11/03 23:43:10 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v 1.4 1999/10/21 07:56:40 akv Exp $ - * $Revision: 1.4 $ - * $Date: 1999/10/21 07:56:40 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/Parser.java,v 1.5 1999/11/03 23:43:10 costin Exp $ + * $Revision: 1.5 $ + * $Date: 1999/11/03 23:43:10 $ * * ==================================================================== * @@ -93,14 +93,6 @@ */ CharArrayWriter caw; - /** - * constants for escapes - */ - private static String QUOTED_START_TAG = "<\\%"; - private static String QUOTED_END_TAG = "%\\>"; - private static String START_TAG = "<%"; - private static String END_TAG = "%>"; - public interface Action { void execute() throws JasperException; } @@ -406,7 +398,7 @@ static { coreElements.addElement(new Comment()); } - + /* * Scripting elements */ @@ -909,33 +901,42 @@ * Entities ' and "e; */ static final class QuoteEscape implements CoreElement { + /** + * constants for escapes + */ + private static String QUOTED_START_TAG = "<\\%"; + private static String QUOTED_END_TAG = "%\\>"; + private static String START_TAG = "<%"; + private static String END_TAG = "%>"; + private static final String APOS = "'"; private static final String QUOTE = ""e;"; + public boolean accept(ParseEventListener listener, JspReader reader, Parser parser) - throws JasperException + throws JasperException { - try { - if (reader.matches(parser.QUOTED_START_TAG)) { - reader.advance(parser.QUOTED_START_TAG.length()); - parser.caw.write(parser.START_TAG); - parser.flushCharData(); - return true; - } else if (reader.matches(APOS)) { - reader.advance(APOS.length()); - parser.caw.write("\'"); - parser.flushCharData(); - return true; - } - else if (reader.matches(QUOTE)) { - reader.advance(QUOTE.length()); - parser.caw.write("\""); - parser.flushCharData(); - return true; - } - } catch (java.io.IOException ex) { - System.out.println (ex.getMessage()); - } - return false; + try { + if (reader.matches(QUOTED_START_TAG)) { + reader.advance(QUOTED_START_TAG.length()); + parser.caw.write(START_TAG); + parser.flushCharData(); + return true; + } else if (reader.matches(APOS)) { + reader.advance(APOS.length()); + parser.caw.write("\'"); + parser.flushCharData(); + return true; + } + else if (reader.matches(QUOTE)) { + reader.advance(QUOTE.length()); + parser.caw.write("\""); + parser.flushCharData(); + return true; + } + } catch (java.io.IOException ex) { + System.out.println (ex.getMessage()); + } + return false; } } @@ -953,12 +954,29 @@ public void parse() throws JasperException { parse(null); } - + public void parse(String until) throws JasperException { + parse(until, null); + } + + public void parse(String until, Class[] accept) throws JasperException { while (reader.hasMoreInput()) { if (until != null && reader.matches(until)) return; - Enumeration e = coreElements.elements(); + + Enumeration e = coreElements.elements(); + + if (accept != null) { + Vector v = new Vector(); + while (e.hasMoreElements()) { + CoreElement c = (CoreElement) e.nextElement(); + for(int i = 0; i < accept.length; i++) + if (c.getClass().equals(accept[i])) + v.addElement(c); + } + e = v.elements(); + } + boolean accepted = false; while (e.hasMoreElements()) { CoreElement c = (CoreElement) e.nextElement(); 1.2 +5 -4 jakarta-tomcat/src/share/org/apache/jasper/compiler/SetPropertyGenerator.java Index: SetPropertyGenerator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/SetPropertyGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SetPropertyGenerator.java 1999/10/09 00:20:38 1.1 +++ SetPropertyGenerator.java 1999/11/03 23:43:12 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/SetPropertyGenerator.java,v 1.1 1999/10/09 00:20:38 duncan Exp $ - * $Revision: 1.1 $ - * $Date: 1999/10/09 00:20:38 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/SetPropertyGenerator.java,v 1.2 1999/11/03 23:43:12 costin Exp $ + * $Revision: 1.2 $ + * $Date: 1999/11/03 23:43:12 $ * * ==================================================================== * @@ -240,7 +240,8 @@ throw new JasperException(m); } else { if (tp.equals(String.class)) - writer.println (name+"."+methodName+"(\"" + value + "\");"); + writer.println (name+"."+methodName+"(" + + writer.quoteString(value) + ");"); else if (tp.equals(char.class)) writer.println (name+"."+methodName+"((new String (\"" + value + "\")).charAt(0));"); 1.6 +8 -9 jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java Index: TagBeginGenerator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TagBeginGenerator.java 1999/10/21 07:57:22 1.5 +++ TagBeginGenerator.java 1999/11/03 23:43:16 1.6 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java,v 1.5 1999/10/21 07:57:22 akv Exp $ - * $Revision: 1.5 $ - * $Date: 1999/10/21 07:57:22 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagBeginGenerator.java,v 1.6 1999/11/03 23:43:16 costin Exp $ + * $Revision: 1.6 $ + * $Date: 1999/11/03 23:43:16 $ * * ==================================================================== * @@ -236,13 +236,13 @@ if (implementsBodyTag) { writer.println("if ("+evalVar+" == Tag.EVAL_BODY_INCLUDE)"); writer.pushIndent(); - writer.println("throw new JspError(\"Since tag handler "+tc.getTagHandlerClass()+ + writer.println("throw new JspTagException(\"Since tag handler "+tc.getTagHandlerClass()+ " implements BodyTag, it can't return Tag.EVAL_BODY_INCLUDE\");"); writer.popIndent(); } else { writer.println("if ("+evalVar+" == BodyTag.EVAL_BODY_TAG)"); writer.pushIndent(); - writer.println("throw new JspError(\"Since tag handler "+tc.getTagHandlerClass()+ + writer.println("throw new JspTagException(\"Since tag handler "+tc.getTagHandlerClass()+ " does not implement BodyTag, it can't return BodyTag.EVAL_BODY_TAG\");"); writer.popIndent(); } @@ -250,11 +250,10 @@ writer.println("if ("+evalVar+" != Tag.SKIP_BODY) {"); writer.pushIndent(); - writer.println("try {"); - writer.pushIndent(); - - if (implementsBodyTag) { + writer.println("try {"); + writer.pushIndent(); + writer.println("if ("+evalVar+" != Tag.EVAL_BODY_INCLUDE) {"); writer.pushIndent(); 1.4 +20 -18 jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java Index: TagEndGenerator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TagEndGenerator.java 1999/10/21 07:57:22 1.3 +++ TagEndGenerator.java 1999/11/03 23:43:18 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java,v 1.3 1999/10/21 07:57:22 akv Exp $ - * $Revision: 1.3 $ - * $Date: 1999/10/21 07:57:22 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagEndGenerator.java,v 1.4 1999/11/03 23:43:18 costin Exp $ + * $Revision: 1.4 $ + * $Date: 1999/11/03 23:43:18 $ * * ==================================================================== * @@ -114,28 +114,30 @@ writer.println("} while (false);"); declareVariables(writer, vi, false, true, VariableInfo.AT_BEGIN); - writer.popIndent(); // try - /** FIXME: REMOVE BEGIN */ - writer.println("} catch (Throwable t) {"); - writer.pushIndent(); - - writer.println("System.err.println(\"Caught: \");"); - writer.println("t.printStackTrace();"); - writer.popIndent(); - /** FIXME: REMOVE END */ - - writer.println("} finally {"); - writer.pushIndent(); if (implementsBodyTag) { + writer.popIndent(); // try + + /** FIXME: REMOVE BEGIN */ + writer.println("} catch (Throwable t) {"); + writer.pushIndent(); + + writer.println("System.err.println(\"Caught: \");"); + writer.println("t.printStackTrace();"); + + writer.popIndent(); + /** FIXME: REMOVE END */ + + writer.println("} finally {"); + writer.pushIndent(); writer.println("if ("+evalVarName+" != Tag.EVAL_BODY_INCLUDE)"); writer.pushIndent(); writer.println("out = pageContext.popBody();"); writer.popIndent(); - } - writer.popIndent(); - writer.println("}"); + writer.popIndent(); + writer.println("}"); + } writer.popIndent(); // EVAL_BODY writer.println("}"); 1.3 +16 -5 jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraries.java Index: TagLibraries.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraries.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TagLibraries.java 1999/10/20 11:22:55 1.2 +++ TagLibraries.java 1999/11/03 23:43:21 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraries.java,v 1.2 1999/10/20 11:22:55 akv Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/20 11:22:55 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraries.java,v 1.3 1999/11/03 23:43:21 costin Exp $ + * $Revision: 1.3 $ + * $Date: 1999/11/03 23:43:21 $ * * ==================================================================== * @@ -68,6 +68,10 @@ import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.Tag; +import org.apache.jasper.Constants; +import org.apache.jasper.JasperException; + + /** * A container for all tag libraries that have been imported using * the taglib directive. @@ -85,13 +89,20 @@ tagLibInfos.put(prefix, tli); } - public boolean isUserDefinedTag(String prefix, String shortTagName) { + public boolean isUserDefinedTag(String prefix, String shortTagName) + throws JasperException + { TagLibraryInfo tli = (TagLibraryInfo) tagLibInfos.get(prefix); if (tli == null) return false; else if (tli.getTag(shortTagName) != null) return true; - return false; + throw new JasperException(Constants.getString("jsp.error.bad_tag", + new Object[] { + shortTagName, + prefix + } + )); } public TagLibraryInfoImpl getTagLibInfo(String prefix) { 1.6 +25 -26 jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java Index: TagLibraryInfoImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TagLibraryInfoImpl.java 1999/10/21 02:47:51 1.5 +++ TagLibraryInfoImpl.java 1999/11/03 23:43:24 1.6 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v 1.5 1999/10/21 02:47:51 mandar Exp $ - * $Revision: 1.5 $ - * $Date: 1999/10/21 02:47:51 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v 1.6 1999/11/03 23:43:24 costin Exp $ + * $Revision: 1.6 $ + * $Date: 1999/11/03 23:43:24 $ * * ==================================================================== * @@ -160,34 +160,41 @@ Constants.WEBAPP_DTD_PUBLIC_ID); NodeList nList = webtld.getElementsByTagName("taglib"); - // Check if a macthing "taglib" exists. + // Check if a matching "taglib" exists. // XXX. Some changes that akv recommended. if (nList.getLength() != 0) { for(int i = 0; i < nList.getLength(); i++) { Element e = (Element) nList.item(i); - NodeList nodeL = e.getChildNodes(); + NodeList list = e.getChildNodes(); String tagLoc = null; boolean match = false; - for(int j = 0; j < nodeL.getLength(); j++) { - Element em = (Element) nodeL.item(j); + for(int j = 0; j < list.getLength(); j++) { + Element em = (Element) list.item(j); String tname = em.getNodeName(); if (tname.equals("taglib-location")) { - tagLoc = ((Text)em.getFirstChild()).getData(); - if (tagLoc != null) - tagLoc = tagLoc.trim(); + Text t = (Text) em.getFirstChild(); + if (t != null) { + tagLoc = t.getData(); + if (tagLoc != null) + tagLoc = tagLoc.trim(); + } } if (tname.equals("taglib-uri")) { - String tmpUri = ((Text)em.getFirstChild()).getData(); - if (tmpUri != null) { - tmpUri = tmpUri.trim(); - if (tmpUri.equals(uriIn)) - match = true; + Text t = (Text) em.getFirstChild(); + if (t != null) { + String tmpUri = t.getData(); + if (tmpUri != null) { + tmpUri = tmpUri.trim(); + if (tmpUri.equals(uriIn)) + match = true; + } } } } - if (match == true && tagLoc != null) this.uri = tagLoc; + if (match == true && tagLoc != null) + this.uri = tagLoc; } - } + } // "uri" should point to the correct tld location. @@ -196,8 +203,6 @@ String actURI = request.getServletPath(); String baseURI = actURI.substring(0, actURI.lastIndexOf('/')); uri = baseURI + '/' + uri; - //url = new URL(uri); - //in = url.openStream(); } //else { //relativeURL = true; @@ -207,7 +212,6 @@ if (in == null) throw new JasperException(Constants.getString("jsp.error.tld_not_found", new Object[] {TLD})); - //Now parse the tld. parseTLD(in); } @@ -462,10 +466,6 @@ Text t = (Text) e.getFirstChild(); if (t != null) rtexprvalue = Boolean.valueOf(t.getData()).booleanValue(); - } else if (tname.equals("reqtime")) { - Text t = (Text) e.getFirstChild(); - if (t != null) - reqTime = Boolean.valueOf(t.getData()).booleanValue(); } else if (tname.equals("type")) { Text t = (Text) e.getFirstChild(); if (t != null) @@ -479,8 +479,7 @@ ); } - return new TagAttributeInfo(name, required, rtexprvalue, type, - reqTime); + return new TagAttributeInfo(name, required, rtexprvalue, type); } static void copy(InputStream in, String fileName) 1.5 +3 -1 jakarta-tomcat/src/share/org/apache/jasper/resources/messages.properties Index: messages.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/resources/messages.properties,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- messages.properties 1999/10/20 21:20:48 1.4 +++ messages.properties 1999/11/03 23:43:41 1.5 @@ -4,6 +4,7 @@ \n in the servlets.properties file for this context. jsp.error.bad.scratch.dir=The scratchDir you specified: {0} is unusable. jsp.message.scratch.dir.is=Scratch dir for the JSP engine is: {0} +jsp.message.parent_class_loader_is=Parent class loader is: {0} jsp.message.dont.modify.servlets=IMPORTANT: Do not modify the generated servlets jsp.error.not.impl.comments=Internal error: Comments not implemented jsp.error.not.impl.directives=Internal error: Directives not implemented @@ -132,4 +133,5 @@ jsp.error.unable.to_load_taghandler_class=Unable to load tag handler class {0} because of {1} jsp.error.unable.to_find_method=Unable to find setter method for attribute: {0} jsp.error.unable.to_introspect=Unable to introspect on tag handler class: {0} because of {1} -jsp.error.invalid_attributes=Attributes are invalid according to TagInfo \ No newline at end of file +jsp.error.invalid_attributes=Attributes are invalid according to TagInfo +jsp.error.bad_tag=No such tag {0} in the tag library imported with prefix {1} \ No newline at end of file 1.3 +19 -37 jakarta-tomcat/src/share/org/apache/jasper/runtime/BodyContentImpl.java Index: BodyContentImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/BodyContentImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BodyContentImpl.java 1999/10/17 08:23:34 1.2 +++ BodyContentImpl.java 1999/11/03 23:43:49 1.3 @@ -1,7 +1,7 @@ /* - * $Id: BodyContentImpl.java,v 1.2 1999/10/17 08:23:34 mode Exp $ - * $Revision: 1.2 $ - * $Date: 1999/10/17 08:23:34 $ + * $Id: BodyContentImpl.java,v 1.3 1999/11/03 23:43:49 costin Exp $ + * $Revision: 1.3 $ + * $Date: 1999/11/03 23:43:49 $ * * ==================================================================== * @@ -160,6 +160,7 @@ reAllocBuff (len); System.arraycopy(cbuf, off, cb, nextChar, len); + nextChar+=len; } } @@ -503,6 +504,11 @@ */ public void clear() throws IOException { + synchronized (lock) { + cb = new char [Constants.DEFAULT_BUFFER_SIZE]; + bufferSize = Constants.DEFAULT_BUFFER_SIZE; + nextChar = 0; + } } /** @@ -515,22 +521,10 @@ */ public void clearBuffer() throws IOException { + this.clear(); } /** - * Flush the stream. If the stream has saved any characters from the - * various write() methods in a buffer, write them immediately to their - * intended destination. Then, if that destination is another character or - * byte stream, flush it. Thus one flush() invocation will flush all the - * buffers in a chain of Writers and OutputStreams. - * - * @exception IOException If an I/O error occurs - */ - - public void flush() throws IOException { - } - - /** * Close the stream, flushing it first. Once a stream has been closed, * further write() or flush() invocations will cause an IOException to be * thrown. Closing a previously-closed stream, however, has no effect. @@ -539,6 +533,9 @@ */ public void close() throws IOException { + synchronized (lock) { + cb = null; + } } /** @@ -557,11 +554,7 @@ * @returns the value of this BodyJspWriter as a Reader */ public Reader getReader() { - //XXX need to optimize this - char[] tmp = new char [ nextChar - 1]; - for (int i=0; i < tmp.length; i++) - tmp[i] = cb[i]; - return new CharArrayReader (tmp); + return new CharArrayReader (cb, 0, nextChar-1); } /** @@ -572,11 +565,7 @@ * @returns the value of the BodyJspWriter as a String */ public String getString() { - //XXX need to optimize this - char[] tmp = new char [ nextChar - 1]; - for (int i=0; i < tmp.length; i++) - tmp[i] = cb[i]; - return new String (tmp); + return new String(cb, 0, nextChar-1); } /** @@ -587,19 +576,12 @@ * @param out The writer into which to place the contents of * this body evaluation */ - public void writeOut(Writer out) { - try { - out.write (cb); - } catch (IOException ioe) { - //What do we do here??? - } + public void writeOut(Writer out) throws IOException { + out.write(cb, 0, nextChar-1); + //Flush not called as the writer passed could be a BodyContent and + //it doesn't allow to flush. } - public void clearBody() { - nextChar = 0; - cb = null; - bufferSize = Constants.DEFAULT_BUFFER_SIZE; - } public static void main (String[] args) throws Exception { char[] buff = {'f','o','o','b','a','r','b','a','z','y'}; 1.7 +14 -9 jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java Index: JspServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JspServlet.java 1999/11/03 20:54:57 1.6 +++ JspServlet.java 1999/11/03 23:43:51 1.7 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v 1.6 1999/11/03 20:54:57 costin Exp $ - * $Revision: 1.6 $ - * $Date: 1999/11/03 20:54:57 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/jasper/runtime/JspServlet.java,v 1.7 1999/11/03 23:43:51 costin Exp $ + * $Revision: 1.7 $ + * $Date: 1999/11/03 23:43:51 $ * * ==================================================================== * @@ -158,7 +158,7 @@ theServlet.service(request, response); } catch (FileNotFoundException ex) { - // ex.printStackTrace(); + ex.printStackTrace(); response.sendError(HttpServletResponse.SC_NOT_FOUND, Constants.getString("jsp.error.file.not.found", new Object[] { @@ -201,10 +201,14 @@ else { options = new Options(config, context); - parentClassLoader = engine.getClassLoader(context); - if (parentClassLoader == null) { + parentClassLoader = (ClassLoader) context.getAttribute(Constants.SERVLET_CLASS_LOADER); + if (parentClassLoader == null) parentClassLoader = this.getClass().getClassLoader(); - } + + Constants.message("jsp.message.parent_class_loader_is", + new Object[] { + parentClassLoader.toString() + }, Constants.MED_VERBOSITY); this.loader = new JspLoader(context, parentClassLoader, @@ -325,6 +329,8 @@ else jspUri = includeUri; + boolean precompile = preCompile(request); + if (Constants.matchVerbosity(Constants.MED_VERBOSITY)) { System.err.println("JspEngine --> "+jspUri); System.err.println("\t ServletPath: "+request.getServletPath()); @@ -340,8 +346,7 @@ System.err.println("\t\t "+name+" = "+request.getParameter(name)); } } - - serviceJspFile(request, response, jspUri, null, preCompile(request)); + serviceJspFile(request, response, jspUri, null, precompile); } catch (RuntimeException e) { throw e; 1.4 +5 -4 jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java Index: ServletLoader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ServletLoader.java 1999/11/03 20:38:54 1.3 +++ ServletLoader.java 1999/11/03 23:43:56 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v 1.3 1999/11/03 20:38:54 costin Exp $ - * $Revision: 1.3 $ - * $Date: 1999/11/03 20:38:54 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletLoader.java,v 1.4 1999/11/03 23:43:56 costin Exp $ + * $Revision: 1.4 $ + * $Date: 1999/11/03 23:43:56 $ * * ==================================================================== * @@ -184,6 +184,7 @@ } private URL getResource(URL base, Enumeration paths, String name) { + return getResource(base, paths, name, false); } @@ -282,7 +283,7 @@ String path = (String)paths.nextElement(); String entryName = name.replace('.', '/') + ".class"; Vector v = new Vector(); - + if (! lib) { v = getPathURL(base, path, entryName); } else {