Re: Taglibs Article

2001-05-26 Thread Nick Bauman

> Nick Bauman wrote:
> 
>> As far as mixing presentation logic and business logic together, well,
>> you can do that with Velocity, too. Although it makes you think longer
>> and harder about it. Here's a recent template snippet I wrote. This is
>> something you wouldn't necessarily be proud of doing with Velocity.
>> 
>> 8<
>> 
>> #foreach( $event in $events )
>>   $yapper = $meeting.getParticipation(
>>   ((MeetingEvent)$event).getFromId() ) #if(
>>   $repRole.equals($yapper.getRole() )
>> $repId = $yapper.getParticipantId()
>> $yapper.getName()
>>   #else
>> $yapper.getName()
>>   #end
>>   #if ( $event.getClass().getName().equals($chatEventType) )
>> ((com.webhelp.emeeting.events.ChatEvent)$event).getStoredData()
>> 
>>   #else if( $event.getClass().getName().equals($urlPushedEventType) )
>> > href="((com.webhelp.emeeting.events.URLPushedEvent)$event).getStoredData
()">((com.webhelp.emeeting.events.URLPushedEvent)$event).getStoredData()

>>   #end
>> #end
> 
> Just out of idle curiousity, why does it look like you are attempting
> to do a cast with the 
> 
> ((com.webhelp.emeeting.events.URLPushedEvent) $event )
> 
> bit?
> 
> Velocity has no such thing as a cast... -> it will introspect and find
> getStoredData() on it's own...

Yeah, I'd discovered that later Very cool!

> And for fun, can someone translate that into JSP tags to see what it
> would look like?

I can show you the JSP because this thing started as JSP once. Not pretty, 
but a Java developer would feel at home, thats about all I could say 
positive about it ;)
 
> geir
> 
> -- 
> Geir Magnusson Jr.   [EMAIL PROTECTED]
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> "still climbing up to the shoulders..."


-- 
Nick Bauman
Software Developer
3023 Lynn #22
Minneapolis, MN
55416
Mobile Phone: (612) 810-7406




cvs commit: jakarta-tomcat/src/shell tomcat.sh

2001-05-26 Thread costin

costin  01/05/26 12:20:29

  Modified:src/shell tomcat.sh
  Log:
  Increase the delay for slower hard disks.
  
  Revision  ChangesPath
  1.24  +3 -3  jakarta-tomcat/src/shell/tomcat.sh
  
  Index: tomcat.sh
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/shell/tomcat.sh,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- tomcat.sh 2001/04/22 15:52:11 1.23
  +++ tomcat.sh 2001/05/26 19:20:28 1.24
  @@ -1,6 +1,6 @@
   #!/bin/sh
   #
  -# $Id: tomcat.sh,v 1.23 2001/04/22 15:52:11 costin Exp $
  +# $Id: tomcat.sh,v 1.24 2001/05/26 19:20:28 costin Exp $
   
   # Shell script to start and stop the server
   
  @@ -144,8 +144,8 @@
 WAIT=0
 if [ "$1" = "-wait" ] ; then
   shift
  -# wait at least 2 min
  -WAIT=120
  +# wait at least 6 min 
  +WAIT=360
 fi
   
 if [ "$1" = "-noout" ] ; then
  
  
  



RE: broken links

2001-05-26 Thread Carlos Gaston Alvarez

It depends on the browser you are using. It works in netscape but not in
internet explorer.

Someone should change the link from
http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod_jk-howto.html
to
http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod%20jk-howto.html

because the space is escaped with a %20

Chau,

Gaston


- Original Message -
From: Marc Saegesser <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 26, 2001 2:46 PM
Subject: RE: broken links


> The first link works OK for me.  I've fixed the second.
>
>
>
> > -Original Message-
> > From: Pier P. Fumagalli [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, May 26, 2001 10:14 AM
> > To: tomcat dev
> > Subject: FW: broken links
> >
> >
> > Can someone take care of those ?
> >
> > Pier
> >
> > -- Forwarded Message
> > From: "Garrey Learmonth" <[EMAIL PROTECTED]>
> > Reply-To: <[EMAIL PROTECTED]>
> > Date: Fri, 25 May 2001 20:38:49 -0700
> > To: <[EMAIL PROTECTED]>
> > Subject: broken links
> >
> > http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod_jk-howto.html
> > http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html
> >
> > regs.,
> >
> > Garrey Learmonth
> > Cisco Systems Inc.
> >
> > -- End of Forwarded Message




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf MessageBytes.java

2001-05-26 Thread costin

costin  01/05/26 11:18:38

  Modified:src/share/org/apache/tomcat/util/buf MessageBytes.java
  Log:
  Added missing method. Efficient implementation later :-)
  
  Revision  ChangesPath
  1.3   +6 -0  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/MessageBytes.java
  
  Index: MessageBytes.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/MessageBytes.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MessageBytes.java 2001/05/26 17:19:58 1.2
  +++ MessageBytes.java 2001/05/26 18:18:38 1.3
  @@ -418,6 +418,12 @@
return strValue.indexOf( s, starting );
   }
   
  +// Inefficient initial implementation. Will be replaced on the next
  +// round of tune-up
  +public int indexOf(String s) {
  + return indexOf( s, 0 );
  +}
  +
   public int indexOfIgnoreCase(String s, int starting) {
toString();
String upper=strValue.toUpperCase();
  
  
  



cvs commit: jakarta-tomcat/src/facade22/org/apache/tomcat/facade HttpServletRequestFacade.java

2001-05-26 Thread costin

costin  01/05/26 11:09:22

  Modified:src/facade22/org/apache/tomcat/facade
HttpServletRequestFacade.java
  Log:
  Call request.handleQueryParameters ( to allow the request to set the
  encoding - the second stage of guessing )
  
  Return unparsed URI.
  
  Revision  ChangesPath
  1.24  +8 -5  
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/HttpServletRequestFacade.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- HttpServletRequestFacade.java 2001/05/15 09:50:37 1.23
  +++ HttpServletRequestFacade.java 2001/05/26 18:09:22 1.24
  @@ -238,7 +238,7 @@
*/
   public String getParameter(String name) {
if( ! parametersProcessed ) {
  - request.parameters().handleQueryParameters();
  + request.handleQueryParameters();
if( request.method().equals("POST")) {
request.handlePostParameters();
}
  @@ -249,7 +249,7 @@
   
   public String[] getParameterValues(String name) {
if( ! parametersProcessed ) {
  - request.parameters().handleQueryParameters();
  + request.handleQueryParameters();
if( request.method().equals("POST")) {
request.handlePostParameters();
}
  @@ -260,7 +260,7 @@
   
   public Enumeration getParameterNames() {
if( ! parametersProcessed ) {
  - request.parameters().handleQueryParameters();
  + request.handleQueryParameters();
if( request.method().equals("POST")) {
request.handlePostParameters();
}
  @@ -291,7 +291,8 @@
   }
   
   public String getQueryString() {
  -String qS=request.queryString().toString();
  + // unprocessed
  + String qS=request.queryString().toString();
if( "".equals(qS) )
return null;
return qS;
  @@ -363,7 +364,9 @@
   }
   
   public String getRequestURI() {
  -return request.requestURI().toString();
  + if( request.unparsedURI().isNull() )
  + return request.requestURI().toString();
  +return request.unparsedURI().toString();
   }
   
   /** Facade: we delegate to the right object ( the context )
  
  
  



cvs commit: jakarta-tomcat/src/etc modules.xml server.xml

2001-05-26 Thread costin

costin  01/05/26 11:07:59

  Modified:src/etc  modules.xml server.xml
  Log:
  Added the decode module.
  
  Revision  ChangesPath
  1.5   +6 -0  jakarta-tomcat/src/etc/modules.xml
  
  Index: modules.xml
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/etc/modules.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- modules.xml   2001/03/31 21:55:06 1.4
  +++ modules.xml   2001/05/26 18:07:59 1.5
  @@ -426,6 +426,12 @@
   
   
   
  +
  +
  +Not yet
  +
  +
  +
   
   
   Not yet
  
  
  
  1.76  +8 -2  jakarta-tomcat/src/etc/server.xml
  
  Index: server.xml
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/etc/server.xml,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- server.xml2001/05/18 19:20:10 1.75
  +++ server.xml2001/05/26 18:07:59 1.76
  @@ -29,8 +29,6 @@
   
   
  - 
  -
   
   
   
  @@ -40,6 +38,7 @@
   
   
   
  +
   
  @@ -142,6 +141,13 @@
   
   
   -->
  +
  +
  +
  + 
  +
  + 
  +
   
   
 
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers DecodeInterceptor.java

2001-05-26 Thread costin

costin  01/05/26 11:04:42

  Added:   src/share/org/apache/tomcat/modules/mappers
DecodeInterceptor.java
  Log:
  Added the initial decoding module.
  
  Code will be added to implement all the common "guessing" schemes
  ( charset/session, etc )
  
  The current code sets UTF8 ( for testing purpose ).
  
  Revision  ChangesPath
  1.1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/DecodeInterceptor.java
  
  Index: DecodeInterceptor.java
  ===
  /*
   * 
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *any, must include the following acknowlegement:  
   *   "This product includes software developed by the 
   *Apache Software Foundation (http://www.apache.org/)."
   *Alternately, this acknowlegement may appear in the software itself,
   *if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *Foundation" must not be used to endorse or promote products derived
   *from this software without prior written permission. For written 
   *permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *nor may "Apache" appear in their names without prior written
   *permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * 
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * .
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.tomcat.modules.mappers;
  
  import org.apache.tomcat.core.*;
  import org.apache.tomcat.util.buf.*;
  import org.apache.tomcat.util.http.*;
  import java.util.*;
  import java.io.*;
  
  /**
   * Default actions after receiving the request: get charset, unescape,
   * pre-process.
   * 
   */
  public class DecodeInterceptor extends  BaseInterceptor  {
  String defaultEncoding=null;
  private int encodingInfo;
  
  public DecodeInterceptor() {
  }
  
  /*  Config   */
  
  /** Set server-wide default encoding. 
   *  UTF-8 is recommended ( if you want to brake the standard spec, which
   *  requires 8859-1 )
   */
  public void setDefaultEncoding( String s ) {
defaultEncoding=s;
  }
  
  /*  Initialization  */
  
  public void engineInit( ContextManager cm )
throws TomcatException
  {
encodingInfo=cm.getNoteId(ContextManager.REQUEST_NOTE,
  "req.encoding" );
  }
  /*  Request mapping  */
  
  public int postReadRequest( Request req ) {
MessageBytes pathMB = req.requestURI();
// copy the request 
  
if( pathMB.isNull())
throw new RuntimeException("ASSERT: null path in request URI");
  
//  if( path.indexOf("?") >=0 )
//  throw new RuntimeException("ASSERT: ? in requestURI");

// Set the char encodi

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/session SessionId.java

2001-05-26 Thread costin

costin  01/05/26 11:03:19

  Modified:src/share/org/apache/tomcat/modules/server Http10.java
   src/share/org/apache/tomcat/modules/session SessionId.java
  Log:
  Use postReadRequest to extract the session id.
  
  Remove the (unused) charset encoding from HTTP10 ( it doesn't deal
  with encoding, just read bytes )
  
  Revision  ChangesPath
  1.11  +0 -1  
jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10.java
  
  Index: Http10.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/server/Http10.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Http10.java   2001/05/21 04:22:33 1.10
  +++ Http10.java   2001/05/26 18:03:19 1.11
  @@ -79,7 +79,6 @@
   int bufSize=2048; // default
   int off=0;
   int count=0;
  -public static final String DEFAULT_CHARACTER_ENCODING = "8859_1";
   
   protected static final int DEFAULT_HEAD_BUFFER_SIZE = 1024;
   protected byte[] oBuffer = new byte[DEFAULT_HEAD_BUFFER_SIZE];
  
  
  
  1.10  +3 -3  
jakarta-tomcat/src/share/org/apache/tomcat/modules/session/SessionId.java
  
  Index: SessionId.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/session/SessionId.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SessionId.java2001/03/21 06:54:01 1.9
  +++ SessionId.java2001/05/26 18:03:19 1.10
  @@ -117,7 +117,7 @@
* similar with the priority in apache hooks, right now it's just
* a config issue.
*/
  -public int contextMap(Request request ) {
  +public int postReadRequest(Request request ) {
if( request.getRequestedSessionId() != null ) {
// probably Apache already did that for us
return 0;
  @@ -131,10 +131,10 @@
// the request.
String sig=";jsessionid=";
int foundAt=-1;
  - String uri=request.requestURI().toString();
String sessionId;

  - if ((foundAt=uri.indexOf(sig))!=-1){
  + if ((foundAt=request.requestURI().indexOf(sig))!=-1){
  + String uri=request.requestURI().toString();
sessionId=uri.substring(foundAt+sig.length());
// rewrite URL, do I need to do anything more?
request.requestURI().setString(uri.substring(0, foundAt));
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers SimpleMapper1.java

2001-05-26 Thread costin

costin  01/05/26 10:54:50

  Modified:src/share/org/apache/tomcat/modules/mappers
SimpleMapper1.java
  Log:
  Don't decode - it'll be done in postReadRequest.
  
  Revision  ChangesPath
  1.3   +0 -11 
jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/SimpleMapper1.java
  
  Index: SimpleMapper1.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/SimpleMapper1.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleMapper1.java2001/02/20 03:16:52 1.2
  +++ SimpleMapper1.java2001/05/26 17:54:50 1.3
  @@ -245,17 +245,6 @@
*/
   public int contextMap( Request req ) {
MessageBytes pathMB = req.requestURI();
  - if( pathMB.isNull())
  - throw new RuntimeException("ASSERT: null path in request URI");
  - //  if( path.indexOf("?") >=0 )
  - //  throw new RuntimeException("ASSERT: ? in requestURI");
  -
  - if (pathMB.indexOf('%') >= 0 || pathMB.indexOf( '+' ) >= 0) {
  - // XXX rewrite URLDecode to avoid allocation
  - log( "Found encoded char - it should have been decoded earlier");
  - pathMB.unescapeURL();
  - // pathMB.setString( RequestUtil.URLDecode(pathMB.toString()) );
  - }
try {
//  String host=null;
MessageBytes hostMB=req.serverName();
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/generators StaticInterceptor.java

2001-05-26 Thread costin

costin  01/05/26 10:54:24

  Modified:src/share/org/apache/tomcat/modules/generators
StaticInterceptor.java
  Log:
  Changed the encoder name. We don't use URLEncoder to avoid conflict with
  the jdk class.
  
  Revision  ChangesPath
  1.13  +2 -2  
jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java
  
  Index: StaticInterceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StaticInterceptor.java2001/05/21 04:05:31 1.12
  +++ StaticInterceptor.java2001/05/26 17:54:23 1.13
  @@ -458,9 +458,9 @@
//  req.setNote( sbNote, buf );
//  }
   
  - Encoder utfEncoder=(Encoder)req.getNote( sbNote );
  + UEncoder utfEncoder=(UEncoder)req.getNote( sbNote );
if( utfEncoder==null ) {
  - utfEncoder=new Encoder();
  + utfEncoder=new UEncoder();
utfEncoder.addSafeCharacter( '/' );
}
   
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Response.java

2001-05-26 Thread costin

costin  01/05/26 10:53:29

  Modified:src/share/org/apache/tomcat/core Response.java
  Log:
  Use standard name for the encoding.
  
  Don't set the charset encoding based on locale - this is not allways correct,
  the user should set it explicitely ( in many countries there are more than
  a possible encoding ).
  
  The code was also buggy, as it used to override the user setting.
  
  Revision  ChangesPath
  1.52  +15 -7 jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Response.java 2001/05/23 03:09:21 1.51
  +++ Response.java 2001/05/26 17:53:29 1.52
  @@ -80,7 +80,7 @@
   
   public static final String DEFAULT_CONTENT_TYPE = "text/plain";
   
  -public static final String DEFAULT_CHAR_ENCODING = "8859_1";
  +public static final String DEFAULT_CHAR_ENCODING = "ISO-8859-1";
   
   public static final String LOCALE_DEFAULT="en";
   
  @@ -113,7 +113,7 @@
   // holds request error URI
   String errorURI=null;
   
  -// 
  +// content type set by user, not including encoding
   protected String contentType = DEFAULT_CONTENT_TYPE;
   protected String contentLanguage = null;
   protected String characterEncoding = DEFAULT_CHAR_ENCODING;
  @@ -410,6 +410,9 @@
   return locale;
   }
   
  +/** Called explicitely by user to set the Content-Language and
  + *  the default encoding
  + */
   public void setLocale(Locale locale) {
   if (locale == null || included) {
   return;  // throw an exception?
  @@ -421,11 +424,16 @@
   // Set the contentLanguage for header output
   contentLanguage = locale.getLanguage();
   
  -// Set the contentType for header output
  -// Use the setContentType() method so encoding is set properly
  -String newType = ContentType.constructLocalizedContentType(contentType,
  -locale);
  -setContentType(newType);
  + // Wrong: if setLocale is called after setContentType, it'll override
  + // the user-value with the default value.
  +// String newType = ContentType.constructLocalizedContentType(
  + // contentType, locale);
  + //setContentType(newType);
  +
  + // Guessing charset from language is inexact - it's better to
  + // not do it.
  + // setContentType must take priority
  + //  characterEncoding = LocaleToCharsetMap.getCharset( locale );
   
// only one header !
headers.setValue("Content-Language").setString( contentLanguage);
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Request.java

2001-05-26 Thread costin

costin  01/05/26 10:51:15

  Modified:src/share/org/apache/tomcat/core Request.java
  Log:
  Code for the changes in buf.
  
  Use standard name for the default encoding.
  
  Added unparsedURIMB - to store the original request URI, to be returned
  by getRequestURI().
  
  Internally we do process the URI, otherwise some mapping may not work
  ( same URI can be encoded in many ways - dependent on browser, charset, etc )
  
  Code for Parameters changes. Save the post buffer if it's small.
  
  Revision  ChangesPath
  1.101 +69 -18jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- Request.java  2001/04/21 18:36:07 1.100
  +++ Request.java  2001/05/26 17:51:15 1.101
  @@ -65,7 +65,7 @@
   import org.apache.tomcat.util.http.ContentType;
   import org.apache.tomcat.util.http.Cookies;
   
  -import org.apache.tomcat.util.buf.MessageBytes;
  +import org.apache.tomcat.util.buf.*;
   
   
   //import org.apache.tomcat.util.http.*;
  @@ -109,6 +109,9 @@
* @author Costin Manolache
*/
   public class Request {
  +// As specified in the servlet specs
  +public static final String DEFAULT_CHARACTER_ENCODING="ISO-8859-1";
  +
   public static final String SESSIONID_FROM_COOKIE="cookie";
   public static final String SESSIONID_FROM_URL="url";
   public static final int MAX_INCLUDE=10;
  @@ -143,6 +146,9 @@
   // that is known only after header parsing. Work in progress.
   protected MessageBytes schemeMB=new MessageBytes();
   
  +// uri without any parsing performed
  +protected MessageBytes unparsedURIMB=new MessageBytes();
  +
   protected MessageBytes methodMB=new MessageBytes();
   protected MessageBytes uriMB=new MessageBytes();
   protected MessageBytes queryMB=new MessageBytes();
  @@ -171,7 +177,8 @@
   // how much body we still have to read.
   protected int available = -1; 
   
  -protected String contentType = null;
  +protected MessageBytes contentTypeMB=null;
  +//protected String contentType = null;
   protected String charEncoding = null;
   protected MessageBytes serverNameMB=new MessageBytes();
   
  @@ -208,6 +215,8 @@
   Request parent;
   Request child;
   
  +UDecoder urlDecoder;
  +
   // Error handling support
   Exception errorException;
   
  @@ -218,7 +227,9 @@
   public Request() {
headers = new MimeHeaders();
scookies = new Cookies( headers );
  + urlDecoder=new UDecoder();
params.setQuery( queryMB );
  + params.setURLDecoder( urlDecoder );
params.setHeaders( headers );
initRequest();  
   }
  @@ -242,9 +253,14 @@
   public Context getContext() {
return context;
   }
  +
  +public UDecoder getURLDecoder() {
  + return urlDecoder;
  +}
   
  -int encodingInfo;
  -int attributeInfo;
  +// cached note ids 
  +private int encodingInfo;
  +private int attributeInfo;
   
   public void setContextManager( ContextManager cm ) {
contextM=cm;
  @@ -298,6 +314,10 @@
return uriMB;
   }
   
  +public MessageBytes unparsedURI() {
  + return unparsedURIMB;
  +}
  +
   public MessageBytes query() {
return queryMB;
   }
  @@ -373,20 +393,39 @@
   
int len=getContentLength();
int available=getAvailable();
  -
  + 
// read only available ( someone else may have read the content )
if( available > 0 ) {
try {
  - byte[] formData = new byte[available];
  + byte[] formData=null;
  + if( available < CACHED_POST_LEN ) {
  + if( postData == null ) postData=new byte[CACHED_POST_LEN];
  + formData=postData;
  + } else {
  + formData = new byte[available];
  + }
readBody( formData, available );
  - params.processData( formData );
  + 
  + handleQueryParameters();
  +
  + params.processParameters( formData, 0, available );
} catch(IOException ex ) {
  + ex.printStackTrace();
// XXX should we throw exception or log ?
return;
}
}
   }
   
  +public void handleQueryParameters() {
  + params.setEncoding( getCharacterEncoding() );
  + params.handleQueryParameters();
  +}
  +
  +// Avoid re-allocating the buffer for each post
  +private static int CACHED_POST_LEN=8192;
  +private byte postData[]=null;
  +
   public Parameters parameters() {
return params;
   }
  @@ -414,14 +453,17 @@
}

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core OutputBuffer.java

2001-05-26 Thread costin

costin  01/05/26 10:46:46

  Modified:src/share/org/apache/tomcat/core OutputBuffer.java
  Log:
  Added the code for the buffer changes. Use ISO-8859-1  (the standard name
  for the default encoding )
  
  Revision  ChangesPath
  1.17  +12 -12
jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- OutputBuffer.java 2001/05/23 03:19:41 1.16
  +++ OutputBuffer.java 2001/05/26 17:46:46 1.17
  @@ -78,10 +78,10 @@
* @author Costin Manolache
*/
   public final class OutputBuffer extends Writer
  -implements ByteBuffer.ByteOutputChannel, CharBuffer.CharOutputChannel 
  +implements ByteChunk.ByteOutputChannel, CharChunk.CharOutputChannel 
   // sink for conversion bytes[]
   {
  -public static final String DEFAULT_ENCODING="8859_1";
  +public static final String DEFAULT_ENCODING="ISO-8859-1";
   public static final int DEFAULT_BUFFER_SIZE = 8*1024;
   private int defaultBufferSize = DEFAULT_BUFFER_SIZE;
   private int defaultCharBufferSize = DEFAULT_BUFFER_SIZE / 2 ;
  @@ -104,8 +104,8 @@
   
   /** The buffer
*/
  -private ByteBuffer bb;
  -private CharBuffer cb;
  +private ByteChunk bb;
  +private CharChunk cb;
   
   String enc;
   boolean gotEnc=false;
  @@ -120,10 +120,10 @@
   
   public OutputBuffer(int size) {
//  buf=new byte[size];
  - bb=new ByteBuffer( size );
  + bb=new ByteChunk( size );
bb.setLimit( size );
bb.setByteOutputChannel( this );
  - cb=new CharBuffer( size );
  + cb=new CharChunk( size );
cb.setCharOutputChannel( this );
cb.setLimit( size );
   }
  @@ -148,14 +148,14 @@
*  @deprecated Used only in Ajp13Packet for a hack
*/
   public int getByteOff() {
  - return bb.getPos();
  + return bb.getOffset();
   }
   
   /** Set the write position in the byte buffer
*  @deprecated Used only in Ajp13Packet for a hack
*/
   public void setByteOff(int c) {
  - bb.setPos(c);
  + bb.setOffset(c);
   }
   
   void log( String s ) {
  @@ -256,7 +256,7 @@
   
   public void write(char c[], int off, int len) throws IOException {
state=CHAR_STATE;
  - if( debug > 0 ) log("write(c,off,len)" + cb.getPos() + " " +
  + if( debug > 0 ) log("write(c,off,len)" + cb.getLength() + " " +
cb.getLimit());
   
cb.append( c, off, len );
  @@ -290,7 +290,7 @@
   } 
   
   public void flushChars() throws IOException {
  - if( debug > 0 ) log("flushChars() " + cb.getPos());
  + if( debug > 0 ) log("flushChars() " + cb.getLength());
cb.flushBuffer();
state=BYTE_STATE;
   }
  @@ -327,7 +327,7 @@
   }
   
   public void realWriteChars( char c[], int off, int len ) throws IOException {
  - if( debug > 0 ) log("realWrite(c,o,l) " + cb.getPos() + " " + len);
  + if( debug > 0 ) log("realWrite(c,o,l) " + cb.getOffset() + " " + len);
if( !gotEnc ) setConverter();

if( debug > 0 ) log("encoder:  " + conv + " " + gotEnc);
  @@ -362,7 +362,7 @@
   /** Real write - this buffer will be sent to the client
*/
   public void flushBytes() throws IOException {
  - if( debug > 0 ) log("flushBytes() " + bb.getLen());
  + if( debug > 0 ) log("flushBytes() " + bb.getLength());
bb.flushBuffer();
   }
   
  
  
  



RE: broken links

2001-05-26 Thread Marc Saegesser

The first link works OK for me.  I've fixed the second.



> -Original Message-
> From: Pier P. Fumagalli [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, May 26, 2001 10:14 AM
> To: tomcat dev
> Subject: FW: broken links
> 
> 
> Can someone take care of those ?
> 
> Pier
> 
> -- Forwarded Message
> From: "Garrey Learmonth" <[EMAIL PROTECTED]>
> Reply-To: <[EMAIL PROTECTED]>
> Date: Fri, 25 May 2001 20:38:49 -0700
> To: <[EMAIL PROTECTED]>
> Subject: broken links
> 
> http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod_jk-howto.html
> http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html
> 
> regs.,
> 
> Garrey Learmonth
> Cisco Systems Inc.
> 
> -- End of Forwarded Message



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java

2001-05-26 Thread costin

costin  01/05/26 10:45:44

  Modified:src/share/org/apache/tomcat/core ContextManager.java
  Log:
  Call the postReadRequest hook.
  
  Revision  ChangesPath
  1.179 +7 -0  
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.178
  retrieving revision 1.179
  diff -u -r1.178 -r1.179
  --- ContextManager.java   2001/05/15 13:06:59 1.178
  +++ ContextManager.java   2001/05/26 17:45:44 1.179
  @@ -842,6 +842,13 @@
   
int status=0;
   BaseInterceptor ri[];
  + ri=defaultContainer.getInterceptors(Container.H_postReadRequest);
  + 
  + for( int i=0; i< ri.length; i++ ) {
  + status=ri[i].postReadRequest( req );
  + if( status!=0 ) return status;
  + }
  +
ri=defaultContainer.getInterceptors(Container.H_contextMap);

for( int i=0; i< ri.length; i++ ) {
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core BaseInterceptor.java Container.java

2001-05-26 Thread costin

costin  01/05/26 10:45:19

  Modified:src/share/org/apache/tomcat/core BaseInterceptor.java
Container.java
  Log:
  Added postReadRequest hook, will be used to decode the request and
  do additional pre-processing ( session id extraction, etc ) - same as in
  the apache's hook with the same name.
  
  Revision  ChangesPath
  1.46  +16 -0 
jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java
  
  Index: BaseInterceptor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BaseInterceptor.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- BaseInterceptor.java  2001/03/09 23:47:39 1.45
  +++ BaseInterceptor.java  2001/05/26 17:45:18 1.46
  @@ -108,6 +108,21 @@
   }
   
   //  Request notifications 
  +
  +/**
  + *  Called immediately after the request has been received, before
  + *  any mapping.
  + *
  + *  This allows modules to alter the request before it is mapped, and
  + *  implement decoding/encoding, detect charsets, etc.
  + *  The request URI and (some) headers will be available.
  + * 
  + *  Similar with Apache's post_read_request
  + */
  +public int postReadRequest(Request request ) {
  + return 0;
  +}
  +
   
   /** Handle mappings inside a context.
*  You are required to respect the mappings in web.xml.
  @@ -115,6 +130,7 @@
   public int requestMap(Request request ) {
return 0;
   }
  +
   /** Will detect the context path for a request.
*  It need to set: context, contextPath, lookupPath
*
  
  
  
  1.50  +19 -17jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java
  
  Index: Container.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Container.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- Container.java2001/03/08 03:51:26 1.49
  +++ Container.java2001/05/26 17:45:18 1.50
  @@ -388,29 +388,31 @@
   
   
   //  Interceptors 
  -public static final int H_requestMap=0;
  -public static final int H_contextMap=1;
  -public static final int H_authenticate=2;
  -public static final int H_authorize=3;
  -public static final int H_preService=4;
  -public static final int H_beforeBody=5;
  -public static final int H_findSession=6;
  -public static final int H_sessionState=7;
  -public static final int H_beforeCommit=8;
  -public static final int H_afterBody=9;
  -public static final int H_postService=10;
  -public static final int H_postRequest=11;
  -public static final int H_handleError=12;
  -public static final int H_getInfo=13;
  -public static final int H_setInfo=14;
  -public static final int H_engineInit=15;
  -public static final int H_COUNT=16;
  +public static final int H_postReadRequest=0;
  +public static final int H_requestMap=1;
  +public static final int H_contextMap=2;
  +public static final int H_authenticate=3;
  +public static final int H_authorize=4;
  +public static final int H_preService=5;
  +public static final int H_beforeBody=6;
  +public static final int H_findSession=7;
  +public static final int H_sessionState=8;
  +public static final int H_beforeCommit=9;
  +public static final int H_afterBody=10;
  +public static final int H_postService=11;
  +public static final int H_postRequest=12;
  +public static final int H_handleError=13;
  +public static final int H_getInfo=14;
  +public static final int H_setInfo=15;
  +public static final int H_engineInit=16;
  +public static final int H_COUNT=17;
   
   Hooks hooks=new Hooks();
   BaseInterceptor hooksCache[][]=null;
   BaseInterceptor allHooksCache[]=null;
   
   private void initHooks() {
  + hooks.registerHook( "postReadRequest", H_postReadRequest );
hooks.registerHook( "requestMap", H_requestMap );
hooks.registerHook( "contextMap", H_contextMap );
hooks.registerHook( "authenticate", H_authenticate );
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/qlog FastDateFormat.java

2001-05-26 Thread costin

costin  01/05/26 10:28:55

  Modified:src/share/org/apache/tomcat/util/qlog FastDateFormat.java
  Log:
  Added a comment in FastDateFormat about the intention to merge it and use it
  for general formating ( not only log )
  
  Small optimization ( append(StringBuffer) )
  
  Revision  ChangesPath
  1.2   +4 -1  
jakarta-tomcat/src/share/org/apache/tomcat/util/qlog/FastDateFormat.java
  
  Index: FastDateFormat.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/qlog/FastDateFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FastDateFormat.java   2001/03/02 04:11:50 1.1
  +++ FastDateFormat.java   2001/05/26 17:28:55 1.2
  @@ -75,6 +75,8 @@
* StringBuffer, FieldPosition).  If you care about the field
* position, call the underlying DateFormat directly.
*
  + * @deprecated This class will be merged with DateTool and moved in buf, to be
  + *   used in all tomcat.
* @author Stan Bailes
* @author Alex Chaffee
**/
  @@ -121,7 +123,8 @@
sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
}
   }
  - toAppendTo.append(sb.toString());
  + toAppendTo.append(sb); // StringBuffer will call toString internally,
  + // except for 1.4 where append(SB) is defined - one more object saved
return toAppendTo;
   }
   
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http AcceptLanguage.java ContentType.java ServerCookie.java

2001-05-26 Thread costin

costin  01/05/26 10:27:20

  Modified:src/share/org/apache/tomcat/util/http AcceptLanguage.java
ContentType.java ServerCookie.java
  Log:
  Added few more comments.
  
  Fixed ContentType detection ( didn't worked corectly, the value "guessed"
  from locale was overriding the user-specified value )
  
  Update ServerCookie to call methods in DateTool ( so later we can move the
  code from FastDateFormat ). ( previously it just used a static field )
  
  Revision  ChangesPath
  1.4   +4 -1  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java
  
  Index: AcceptLanguage.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AcceptLanguage.java   2001/02/20 03:14:11 1.3
  +++ AcceptLanguage.java   2001/05/26 17:27:19 1.4
  @@ -65,7 +65,10 @@
   import java.text.*;
   
   /**
  - * 
  + * Util to process the "Accept-Language" header. Used by facade to implement
  + * getLocale() and by StaticInterceptor.
  + *
  + * Not optimized - it's very slow.
* 
* @author James Duncan Davidson [[EMAIL PROTECTED]]
* @author James Todd [[EMAIL PROTECTED]]
  
  
  
  1.5   +22 -19
jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java
  
  Index: ContentType.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContentType.java  2001/03/15 23:06:18 1.4
  +++ ContentType.java  2001/05/26 17:27:19 1.5
  @@ -89,7 +89,7 @@
   if (charsetLocation == -1) {
   return null;
   }
  -String afterCharset = type.substring(charsetLocation + 8);
  + String afterCharset = type.substring(charsetLocation + 8);
   // The charset value in a Content-Type header is allowed to be quoted
   // and charset values can't contain quotes.  Just convert any quote
   // chars into spaces and let trim clean things up.
  @@ -98,25 +98,28 @@
   return encoding;
   }
   
  -/** Utility method for parsing the mime type and setting
  - *  the encoding to locale. Also, convert from java Locale to mime
  - * encodings
  - */
  -public static String constructLocalizedContentType(String type,
  - Locale loc) {
  -// Cut off everything after the semicolon
  -int semi = type.indexOf(";");
  -if (semi != -1) {
  -type = type.substring(0, semi);
  -}
   
  -// Append the appropriate charset, based on the locale
  -String charset = LocaleToCharsetMap.getCharset(loc);
  -if (charset != null) {
  -type = type + "; charset=" + charset;
  -}
  +// Bad method: the user may set the charset explicitely
  +
  +// /** Utility method for parsing the mime type and setting
  +//  *  the encoding to locale. Also, convert from java Locale to mime
  +//  *  encodings
  +//  */
  +// public static String constructLocalizedContentType(String type,
  +//   Locale loc) {
  +// // Cut off everything after the semicolon
  +// int semi = type.indexOf(";");
  +// if (semi != -1) {
  +// type = type.substring(0, semi);
  +// }
   
  -return type;
  -}
  +// // Append the appropriate charset, based on the locale
  +// String charset = LocaleToCharsetMap.getCharset(loc);
  +// if (charset != null) {
  +// type = type + "; charset=" + charset;
  +// }
  +
  +// return type;
  +// }
   
   }
  
  
  
  1.9   +2 -3  
jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java
  
  Index: ServerCookie.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServerCookie.java 2001/02/20 03:14:11 1.8
  +++ ServerCookie.java 2001/05/26 17:27:19 1.9
  @@ -230,8 +230,7 @@
   }
   }
   
  -private static final String ancientDate=DateTool.oldCookieFormat
  - .format(new Date(1));
  +private static final String ancientDate=DateTool.formatOldCookie(new 
Date(1));
   
   public static void appendCookieValue( StringBuffer buf,
  int version,
  @@ -280,7 +279,7 @@
   if (maxAge == 0)
buf.append( ancientDate );
else
  -DateT

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/http Parameters.java

2001-05-26 Thread costin

costin  01/05/26 10:24:17

  Modified:src/share/org/apache/tomcat/util/http Parameters.java
  Log:
  Few big changes here...
  
  The "new" code is now in use ( has been here for few months, but we kept
  using the old code for safety ). The most important thing is that
  now we corectly decode ( if charset is provided ) - the old code didn't.
  
  There is still some old code in use ( only used by RequestDispatcher), but
  the common code is now fixed.
  
  Revision  ChangesPath
  1.12  +182 -84   
jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java
  
  Index: Parameters.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Parameters.java   2001/02/20 03:14:11 1.11
  +++ Parameters.java   2001/05/26 17:24:17 1.12
  @@ -59,9 +59,7 @@
   
   package org.apache.tomcat.util.http;
   
  -import  org.apache.tomcat.util.buf.MessageBytes;
  -import  org.apache.tomcat.util.buf.CharChunk;
  -import  org.apache.tomcat.util.buf.ByteChunk;
  +import  org.apache.tomcat.util.buf.*;
   import  org.apache.tomcat.util.collections.MultiMap;
   import java.io.*;
   import java.util.*;
  @@ -72,6 +70,7 @@
* @author Costin Manolache
*/
   public final class Parameters extends MultiMap {
  +
   // Transition: we'll use the same Hashtable( String->String[] )
   // for the beginning. When we are sure all accesses happen through
   // this class - we can switch to MultiMap
  @@ -81,6 +80,9 @@
   
   MessageBytes queryMB;
   MimeHeaders  headers;
  +
  +UDecoder urlDec;
  +MessageBytes decodedQuery=new MessageBytes();
   
   public static final int INITIAL_SIZE=4;
   
  @@ -94,6 +96,8 @@
   private Parameters parent=null;
   private Parameters currentChild=null;
   
  +String encoding=null;
  +
   /**
* 
*/
  @@ -109,12 +113,18 @@
this.headers=headers;
   }
   
  +public void setEncoding( String s ) {
  + encoding=s;
  +}
  +
   public void recycle() {
super.recycle();
paramHashStringArray.clear();
didQueryParameters=false;
currentChild=null;
didMerge=false;
  + encoding=null;
  + decodedQuery.recycle();
   }
   
   //  Sub-request support 
  @@ -145,11 +155,13 @@
// set child to null !
if( currentChild==null ) {
currentChild=new Parameters();
  + currentChild.setURLDecoder( urlDec );
currentChild.parent=this;
return;
}
if( currentChild.child==null ) {
currentChild.child=new Parameters();
  + currentChild.setURLDecoder( urlDec );
currentChild.child.parent=currentChild;
} // it is not null if this object already had a child
// i.e. a deeper include() ( we keep it )
  @@ -205,9 +217,10 @@
*/
   private void merge() {
// recursive
  - //  System.out.println("Merging " + this + " with " +
  - // parent + " " + didMerge);
  - //System.out.println( "Before " + paramsAsString());
  + if( debug > 0 ) {
  + log("Before merging " + this + " " + parent + " " + didMerge );
  + log(  paramsAsString());
  + }
// Local parameters first - they take precedence as in spec.
handleQueryParameters();
   
  @@ -222,7 +235,8 @@
Hashtable parentProps=parent.paramHashStringArray;
merge2( paramHashStringArray , parentProps);
didMerge=true;
  - //System.out.println( "After " + paramsAsString());
  + if(debug > 0 )
  + log("After " + paramsAsString());
   }
   
   
  @@ -231,54 +245,34 @@
String[] values = getParameterValues(name);
   if (values != null) {
if( values.length==0 ) return "";
  - //System.out.println("XXX " + name + "=" + values[0] );
   return values[0];
   } else {
  - //  System.out.println("XXX " + name + "=null" );
return null;
   }
   }
   //  Processing 
  -
   /** Process the query string into parameters
*/
   public void handleQueryParameters() {
if( didQueryParameters ) return;

didQueryParameters=true;
  - if( queryMB==null )
  + if( debug > 0  )
  + log( "Decoding query " + queryMB + " " + encoding);
  + 
  + if( queryMB==null || queryMB.isNull() )
return;
  - String qString=queryMB.toString();
  - if(qString!=null) {
  - processFormData( qString );
  - }
  -}
  -
  -public void processParameters(String data) {
  - processFormData( data );
  -}
  -
  -// XXX ENCODING !!
  -public void proc

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf TimeStamp.java

2001-05-26 Thread costin

costin  01/05/26 10:20:20

  Modified:src/share/org/apache/tomcat/util/buf TimeStamp.java
  Log:
  Added a small comment that TimeStamp doesn't belong here :-)
  
  Revision  ChangesPath
  1.2   +1 -0  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/TimeStamp.java
  
  Index: TimeStamp.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/TimeStamp.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TimeStamp.java2001/02/27 18:23:07 1.1
  +++ TimeStamp.java2001/05/26 17:20:19 1.2
  @@ -67,6 +67,7 @@
   import java.util.Hashtable;
   import java.util.Vector;
   
  +// XXX Shouldn't be here - has nothing to do with buffers.
   
   /**
* Main tool for object expiry. 
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf MessageBytes.java

2001-05-26 Thread costin

costin  01/05/26 10:19:58

  Modified:src/share/org/apache/tomcat/util/buf MessageBytes.java
  Log:
  Added comments about deprecation of int/date cache.
  
  Added duplicate() method that will copy another buffer ( will be used to
  save the un-processed url, query string for servlet use )
  
  Revision  ChangesPath
  1.2   +114 -86   
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/MessageBytes.java
  
  Index: MessageBytes.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/MessageBytes.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MessageBytes.java 2001/02/20 03:12:13 1.1
  +++ MessageBytes.java 2001/05/26 17:19:58 1.2
  @@ -62,10 +62,8 @@
   import java.text.*;
   import java.util.*;
   import java.io.Serializable;
  +import java.io.IOException;
   
  -// XXX XXX Need StringBuffer support !
  -
  -
   /**
* This class is used to represent a subarray of bytes in an HTTP message.
*
  @@ -74,8 +72,6 @@
* @author Costin Manolache
*/
   public final class MessageBytes implements Cloneable, Serializable {
  -public static final String DEFAULT_CHAR_ENCODING="8859_1";
  -
   // primary type ( whatever is set as original value )
   private int type = T_NULL;
   
  @@ -97,14 +93,6 @@
   private String strValue;
   private boolean hasStrValue=false;
   
  -// efficient int and date
  -// XXX used only for headers - shouldn't be
  -// stored here.
  -private int intValue;
  -private boolean hasIntValue=false;
  -private Date dateValue;
  -private boolean hasDateValue=false;
  -
   /**
* Creates a new, uninitialized MessageBytes object.
*/
  @@ -180,31 +168,6 @@
type=T_STR;
   }
   
  -public void setTime(long t) {
  - // XXX replace it with a byte[] tool
  - recycle();
  - if( dateValue==null)
  - dateValue=new Date(t);
  - else
  - dateValue.setTime(t);
  - strValue=DateTool.rfc1123Format.format(dateValue);
  - hasStrValue=true;
  - hasDateValue=true;
  - type=T_STR;   
  -}
  -
  -/** Set the buffer to the representation of an int 
  - */
  -public void setInt(int i) {
  - // XXX replace it with a byte[] tool
  - recycle();
  - strValue=String.valueOf( i );
  - intValue=i;
  - hasIntValue=true;
  - hasStrValue=true;
  - type=T_STR;
  -}
  -
   //  Conversion and getters 
   public String toString() {
if( hasStrValue ) return strValue;
  @@ -220,42 +183,7 @@
}
return null;
   }
  -
  -public long getTime()
  -{
  - if( hasDateValue ) {
  - if( dateValue==null) return -1;
  - return dateValue.getTime();
  - }
  - 
  - long l=DateTool.parseDate( this );
  - if( dateValue==null)
  - dateValue=new Date(l);
  - else
  - dateValue.setTime(l);
  - hasDateValue=true;
  - return l;
  -}
  -
   
  -/** Convert the buffer to an int, cache the value
  - */ 
  -public int getInt() 
  -{
  - if( hasIntValue )
  - return intValue;
  - 
  - switch (type) {
  - case T_BYTES:
  - intValue=byteC.getInt();
  - break;
  - default:
  - intValue=Integer.parseInt(toString());
  - }
  - hasIntValue=true;
  - return intValue;
  -}
  -
   //
   public int getType() {
return type;
  @@ -272,6 +200,10 @@
return charC;
   }
   
  +public String getString() {
  + return strValue;
  +}
  +
   // Convert to bytes !!!
   public void toBytes() {
// XXX todo - not used 
  @@ -300,6 +232,7 @@
if(type==T_STR)
return strValue.length();
toString();
  + if( strValue==null ) return 0;
return strValue.length();
   }
   
  @@ -345,19 +278,6 @@
}
   }
   
  -public int unescapeURL() {
  - switch (type) {
  - case T_STR:
  - if( strValue==null ) return 0;
  - strValue=CharChunk.unescapeURL( strValue );
  - case T_CHARS:
  - return charC.unescapeURL();
  - case T_BYTES:
  - return byteC.unescapeURL();
  - }
  - return 0;
  -}
  -
   public boolean equals(MessageBytes mb) {
switch (type) {
case T_STR:
  @@ -522,5 +442,113 @@
}
   }
   
  +/** Copy the src into this MessageBytes, allocating more space if
  + *  needed
  + */
  +public void duplicate( MessageBytes src ) throws IOException
  +{
  + switch( src.getType() ) {
  + case MessageBytes.T_BYTES:
  + type=T_BYTES;
  + ByteChunk bc=

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf DateTool.java

2001-05-26 Thread costin

costin  01/05/26 10:18:54

  Modified:src/share/org/apache/tomcat/util/buf DateTool.java
  Log:
  Added comments about deprecation of few methods. The whole thing must
  be replaced with FastDateFormat.
  
  Revision  ChangesPath
  1.3   +45 -14
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/DateTool.java
  
  Index: DateTool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/DateTool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DateTool.java 2001/05/21 15:07:17 1.2
  +++ DateTool.java 2001/05/26 17:18:54 1.3
  @@ -69,6 +69,8 @@
   /**
*  Common place for date utils.
*
  + * @deprecated Will be replaced with a more efficient impl, based on
  + * FastDateFormat, with an API using less objects.
* @author [EMAIL PROTECTED]
* @author Jason Hunter [[EMAIL PROTECTED]]
* @author James Todd [[EMAIL PROTECTED]]
  @@ -78,16 +80,16 @@
   
   /** US locale - all HTTP dates are in english
*/
  -public final static Locale LOCALE_US = Locale.US;
  +private final static Locale LOCALE_US = Locale.US;
   
   /** GMT timezone - all HTTP dates are on GMT
*/
  -public final static TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
  +private final static TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
   
   /** format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
*/
  -public final static String RFC1123_PATTERN =
  -"EEE, dd MMM y HH:mm:ss z";
  +private final static String RFC1123_PATTERN =
  +"EEE, dd MMM  HH:mm:ss z";
   
   // format for RFC 1036 date string -- "Sunday, 06-Nov-94 08:49:37 GMT"
   private final static String rfc1036Pattern =
  @@ -95,26 +97,27 @@
   
   // format for C asctime() date string -- "Sun Nov  6 08:49:37 1994"
   private final static String asctimePattern =
  -"EEE MMM d HH:mm:ss y";
  +"EEE MMM d HH:mm:ss ";
   
   /** Pattern used for old cookies
*/
  -public final static String OLD_COOKIE_PATTERN = "EEE, dd-MMM- HH:mm:ss z";
  +private final static String OLD_COOKIE_PATTERN = "EEE, dd-MMM- HH:mm:ss z";
   
  -/** DateFormat to be used to format dates
  +/** DateFormat to be used to format dates. Called from MessageBytes
*/
  -public final static DateFormat rfc1123Format =
  +private final static DateFormat rfc1123Format =
new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US);
   
   /** DateFormat to be used to format old netscape cookies
  + Called from ServerCookie
*/
  -public final static DateFormat oldCookieFormat =
  +private final static DateFormat oldCookieFormat =
new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US);
   
  -public final static DateFormat rfc1036Format =
  +private final static DateFormat rfc1036Format =
new SimpleDateFormat(rfc1036Pattern, LOCALE_US);
   
  -public final static DateFormat asctimeFormat =
  +private final static DateFormat asctimeFormat =
new SimpleDateFormat(asctimePattern, LOCALE_US);
   
   static {
  @@ -126,11 +129,39 @@

   private static StringManager sm =
   StringManager.getManager("org.apache.tomcat.resources");
  -
  -public static long parseDate( MessageBytes value ) {
  - return parseDate( value.toString());
  +
  +// Called from MessageBytes.getTime()
  +static long parseDate( MessageBytes value ) {
  + return parseDate( value.toString());
  +}
  +
  +// Called from MessageBytes.setTime
  +/** 
  + */
  +public static String format1123( Date d ) {
  + return rfc1123Format.format( d );
  +} 
  +
  +
  +// Called from ServerCookie
  +/** 
  + */
  +public static void formatOldCookie( Date d, StringBuffer sb,
  +   FieldPosition fp )
  +{
  + oldCookieFormat.format( d, sb, fp );
  +}
  +
  +// Called from ServerCookie
  +public static String formatOldCookie( Date d )
  +{
  + return oldCookieFormat.format( d );
   }
   
  +
  +/** Called from HttpServletRequest.getDateHeader().
  + Not efficient - but not very used.
  + */
   public static long parseDate( String dateString ) {
Date date=null;
   try {
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf C2BConverter.java

2001-05-26 Thread costin

costin  01/05/26 10:18:20

  Modified:src/share/org/apache/tomcat/util/buf C2BConverter.java
  Log:
  Updated to use ByteChunk/CharChunk.
  
  Revision  ChangesPath
  1.2   +11 -9 
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/C2BConverter.java
  
  Index: C2BConverter.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/C2BConverter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- C2BConverter.java 2001/05/21 03:46:29 1.1
  +++ C2BConverter.java 2001/05/26 17:18:20 1.2
  @@ -60,6 +60,8 @@
   
   package org.apache.tomcat.util.buf;
   
  +import org.apache.tomcat.util.buf.*;
  +
   import java.io.*;
   
   /** Efficient conversion of character to bytes.
  @@ -72,11 +74,11 @@
   public final class C2BConverter {
   private IntermediateOutputStream ios;
   private WriteConvertor conv;
  -private ByteBuffer bb;
  +private ByteChunk bb;
   
   /** Create a converter, with bytes going to a byte buffer
*/
  -public C2BConverter(ByteBuffer output, String encoding) throws IOException {
  +public C2BConverter(ByteChunk output, String encoding) throws IOException {
this.bb=output;
ios=new IntermediateOutputStream( output );
conv=new WriteConvertor( ios, encoding );
  @@ -85,16 +87,16 @@
   /** Create a converter
*/
   public C2BConverter(String encoding) throws IOException {
  - this( new ByteBuffer(), encoding );
  + this( new ByteChunk(1024), encoding );
   }
   
  -public ByteBuffer getByteBuffer() {
  +public ByteChunk getByteChunk() {
return bb;
   }
   
  -public void setByteBuffer(ByteBuffer bb) {
  +public void setByteChunk(ByteChunk bb) {
this.bb=bb;
  - ios.setByteBuffer( bb );
  + ios.setByteChunk( bb );
   }
   
   /** Reset the internal state, empty the buffers.
  @@ -209,10 +211,10 @@
   not be called if recycling the converter and if data was not flushed.
   */
   final class IntermediateOutputStream extends OutputStream {
  -private ByteBuffer tbuff;
  +private ByteChunk tbuff;
   private boolean enabled=true;
   
  -public IntermediateOutputStream(ByteBuffer tbuff) {
  +public IntermediateOutputStream(ByteChunk tbuff) {
this.tbuff=tbuff;
   }
   
  @@ -239,7 +241,7 @@
   
   //  Internal methods 
   
  -void setByteBuffer( ByteBuffer bb ) {
  +void setByteChunk( ByteChunk bb ) {
tbuff=bb;
   }
   
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java CharChunk.java

2001-05-26 Thread costin

costin  01/05/26 10:17:02

  Modified:src/share/org/apache/tomcat/util/buf ByteChunk.java
CharChunk.java
  Log:
  Merged the resizable and flush-able buffer code from OutputBuffer.
  
  Now the CharChunk and ByteChunk can be used as general-purpose buffers
  ( instead of StringBuffer for example ) - i.e. both input and output.
  
  Most of the code is old and well tested ( has been part of OutputBuffer for
  a while ), we just moved it here to be of more use.
  
  We preserved all the old API, except for url decoding ( which has been
  almost completely rewritten ).
  
  Some methods are now deprecated and could be removed ( we haven't frozen the
  API - if we ship 3.3 with those in it'll be hard to remove later ).
  The caching of header conversion result should be part of MimeHeaders, and
  not affect the buffers.
  
  Revision  ChangesPath
  1.3   +313 -220  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ByteChunk.java2001/03/10 18:18:43 1.2
  +++ ByteChunk.java2001/05/26 17:17:01 1.3
  @@ -62,11 +62,9 @@
   import java.text.*;
   import java.util.*;
   import java.io.Serializable;
  +import java.io.IOException;
   
  -/**
  - * This class is used to represent a chunk of bytes, and
  - * utilities to manipulate byte[].
  - *
  +/*
* In a server it is very important to be able to operate on
* the original byte[] without converting everything to chars.
* Some protocols are ASCII only, and some allow different
  @@ -78,26 +76,60 @@
* For HTTP it is not very clear how the encoding of RequestURI
* and mime values can be determined, but it is a great advantage
* to be able to parse the request without converting to string.
  + */
  +
  +
  +/**
  + * This class is used to represent a chunk of bytes, and
  + * utilities to manipulate byte[].
  + *
  + * The buffer can be modified and used for both input and output.
*
* @author [EMAIL PROTECTED]
* @author James Todd [[EMAIL PROTECTED]]
* @author Costin Manolache
*/
   public final class ByteChunk implements Cloneable, Serializable {
  +// Output interface, used when the buffer is filled.
  +public static interface ByteOutputChannel {
  + /** Send the bytes ( usually the internal conversion buffer ).
  +  *  Expect 8k output if the buffer is full.
  +  */
  + public void realWriteBytes( byte cbuf[], int off, int len)
  + throws IOException;
  +}
  +
  +// 
  +
   // byte[]
  -private byte[] bytes;
  -private int bytesOff;
  -private int bytesLen;
  +private byte[] buff;
  +
  +private int start=0;
  +private int end;
  +
   private String enc;
  -private boolean isSet=false;
  +
  +private boolean isSet=false; // XXX
  +
  +// How much can it grow, when data is added
  +private int limit=-1;
  +
  +private ByteOutputChannel out=null;
  +
  +private boolean isOutput=false;
   
   /**
* Creates a new, uninitialized ByteChunk object.
*/
   public ByteChunk() {
   }
  +
  +public ByteChunk( int initial ) {
  + allocate( initial, -1 );
  +}
   
  -public ByteChunk getClone() {
  +//
  +public ByteChunk getClone() {
try {
return (ByteChunk)this.clone();
} catch( Exception ex) {
  @@ -106,18 +138,37 @@
   }
   
   public boolean isNull() {
  - return ! isSet; // bytes==null;
  + return ! isSet; // buff==null;
   }
   
   /**
  - * Resets the message bytes to an uninitialized state.
  + * Resets the message buff to an uninitialized state.
*/
   public void recycle() {
  - bytes = null;
  + //  buff = null;
enc=null;
  + start=0;
  + end=0;
isSet=false;
   }
   
  +public void reset() {
  + buff=null;
  +}
  +
  +//  Setup 
  +
  +public void allocate( int initial, int limit  ) {
  + isOutput=true;
  + if( buff==null || buff.length < initial ) {
  + buff=new byte[initial];
  + }
  + this.limit=limit;
  + start=0;
  + end=0;
  + isSet=true;
  +}
  +
   /**
* Sets the message bytes to the specified subarray of bytes.
* 
  @@ -126,9 +177,9 @@
* @param len the length of the bytes
*/
   public void setBytes(byte[] b, int off, int len) {
  - bytes = b;
  - bytesOff = off;
  - bytesLen = len;
  + buff = b;
  + start = off;
  + end = start+ len;
isSet=true;
   }
   
  @@ -136,158 +187,249 @@
this.enc=

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf package.html

2001-05-26 Thread costin

costin  01/05/26 10:12:26

  Added:   src/share/org/apache/tomcat/util/buf package.html
  Log:
  Few comments ( I'll expand later )
  
  Revision  ChangesPath
  1.1  jakarta-tomcat/src/share/org/apache/tomcat/util/buf/package.html
  
  Index: package.html
  ===
  Buffers and Encodings
  
  This package contains buffers and utils to perform encoding/decoding of buffers. 
That includes byte to char
  conversions, URL encodings, etc. 
  
  
  Encoding is a critical operation for performance. There are few tricks in this 
package - the C2B and 
  B2C converters are caching a ISReader/OSWriter and keep everything allocated to do 
the conversions 
  in any VM without any garbage.
  
  
  This package must accomodate future extensions and additional converters ( most 
imporant: the nio.charset, 
  which should be detected and used if available ). Also, we do have one hand-written 
UTF8Decoder, and 
  other tuned encoders could be added.
  
  
  My benchmarks ( I'm costin :-) show only small differences between C2B, B2C and 
hand-written codders/decoders,
  so UTF8Decoder may be disabled. 
  
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf UTF8Decoder.java B2CConverter.java

2001-05-26 Thread costin

costin  01/05/26 10:12:05

  Added:   src/share/org/apache/tomcat/util/buf UTF8Decoder.java
B2CConverter.java
  Log:
  Added a generic Byte->Char (charset) decoder, using the same model as
  the C2BConverter used by OutputBuffer.
  
  The input system is still very inefficient, this is just the first step
  ( not used in active code - I did a lot of tests but it's better to be
  safe for now, and make sure we don't have regressions with the other changes
  before activating this one ).
  
  UTF8Decoder used to be part of ByteChunk, it was fixed and tested with
  multi-byte chars.
  
  The decoding was refactored for 3 reasons:
  1. Performance. This way we can optimize individual converters and plug
  specialized versions ( like UTF8 )
  2. We should be able to use ( when detected ) nio converters
  3. Clarity. It's ( IMHO ) easier to follow the Chunk code without all the
  extra ( and complex ) decoding code in.
  
  Both clases are not in use in the current code, but should be enabled
  for 3.3 - the code is stable and efficient.
  
  Revision  ChangesPath
  1.1  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/UTF8Decoder.java
  
  Index: UTF8Decoder.java
  ===
  /*
   * 
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *any, must include the following acknowlegement:  
   *   "This product includes software developed by the 
   *Apache Software Foundation (http://www.apache.org/)."
   *Alternately, this acknowlegement may appear in the software itself,
   *if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *Foundation" must not be used to endorse or promote products derived
   *from this software without prior written permission. For written 
   *permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *nor may "Apache" appear in their names without prior written
   *permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * 
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * .
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.tomcat.util.buf;
  
  import java.text.*;
  import java.util.*;
  import java.io.Serializable;
  import java.io.IOException;
  import org.apache.tomcat.util.buf.*;
  
  /**
   * Moved from ByteChunk - code to convert from UTF8 bytes to chars.
   * Not used in the current tomcat3.3 : the performance gain is not very
   * big if the String is created, only if we avoid that and work only
   * on char[]. Until than, it's better to be safe. ( I tested this code
   * with 2 and 3 bytes chars, and it works fine in xerces )
   * 
   * Cut from xerces' UTF8Reader.copyMultiByteCharData() 
   *
   * @author Costin Manolache
   * @author ( Xml-Xerces )
   */
  public final class UTF8Decoder extends B2CConverter {
  // may have state !!
  
  public UTF8Decoder() {
  
  }
  
  public void recycle() {
  

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf UDecoder.java UEncoder.java

2001-05-26 Thread costin

costin  01/05/26 10:07:31

  Added:   src/share/org/apache/tomcat/util/buf UDecoder.java
UEncoder.java
  Log:
  Added ( refactored ) UTF encoder and decoder.
  
  The code used to be part of Byte/Char Chunk, but had many bugs and it was hard
  to optimize.
  
  Note that we don't implement M$ encoding scheme ( which is not standard and
  may cause many problems ), but it could be implemented.
  
  There is still work to be done for decoding char[] - the result of the
  conversion is byte, and it has to be converted ( somehow ) to char, but
  you can't do that without a b->c converter.
  
  ( this will happen for RequestDispatchers for example - a workaround is to
  not encode "extended" chars )
  
  Revision  ChangesPath
  1.1  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/UDecoder.java
  
  Index: UDecoder.java
  ===
  /*
   * 
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *any, must include the following acknowlegement:  
   *   "This product includes software developed by the 
   *Apache Software Foundation (http://www.apache.org/)."
   *Alternately, this acknowlegement may appear in the software itself,
   *if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *Foundation" must not be used to endorse or promote products derived
   *from this software without prior written permission. For written 
   *permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *nor may "Apache" appear in their names without prior written
   *permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * 
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * .
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  package org.apache.tomcat.util.buf;
  
  import org.apache.tomcat.util.buf.*;
  
  import java.util.BitSet;
  import java.io.*;
  
  /** 
   *  All URL decoding happens here. This way we can reuse, review, optimize
   *  without adding complexity to the buffers.
   *
   *  The conversion will modify the original buffer.
   * 
   *  @author Costin Manolache
   */
  public final class UDecoder {
  
  public UDecoder() 
  {
  }
  
  /** URLDecode, will modify the source.
   */
  public void convert(ByteChunk mb)
throws IOException
  {
int start=mb.getOffset();
byte buff[]=mb.getBytes();
int end=mb.getEnd();
  
int idx= mb.indexOf( buff, start, end, '%' );
int idx2= mb.indexOf( buff, start, end, '+' );
if( idx<0 && idx2<0 ) {
return;
}

if( idx2 >= 0 && idx2 < idx ) idx=idx2; 

for( int j=idx; j= end ) {
throw new CharConversionException("EOF");
}
byte b1= buff[j+1];
byte b2=buff[j+2];
if( !isHexDigit( b1 ) || ! isHexDigit(b2 ))
throw new Char

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteBuffer.java CharBuffer.java Encoder.java

2001-05-26 Thread costin

costin  01/05/26 10:03:02

  Removed: src/share/org/apache/tomcat/util/buf ByteBuffer.java
CharBuffer.java Encoder.java
  Log:
  Removed the Byte,Char Buffer. The code was merged in ByteChunk, CharChunk -
  it was confusing to have 2 and hard to work with it ( conversions, etc )



cvs commit: jakarta-tomcat/src/doc index.html

2001-05-26 Thread marcsaeg

marcsaeg01/05/26 09:04:14

  Modified:src/doc  Tag: tomcat_32 index.html
  Log:
  Fixed HREF for documentation home page to match the new Tomcat web site.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.5.2.6   +2 -2  jakarta-tomcat/src/doc/index.html
  
  Index: index.html
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/doc/index.html,v
  retrieving revision 1.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- index.html2000/11/29 18:01:54 1.5.2.5
  +++ index.html2001/05/26 16:04:14 1.5.2.6
  @@ -1,7 +1,7 @@
   
   
 
  -
  +
   
   
   
  @@ -87,7 +87,7 @@
   
   
   
  -* The absolute latest Tomcat documentation can be found online at the http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html";>Tomcat
  +* The absolute latest Tomcat documentation can be found online at the http://jakarta.apache.org/tomcat/tomcat-3.2-doc/index.html";>Tomcat
   Documentation homepage.
   
   
  
  
  



FW: broken links

2001-05-26 Thread Pier P. Fumagalli

Can someone take care of those ?

Pier

-- Forwarded Message
From: "Garrey Learmonth" <[EMAIL PROTECTED]>
Reply-To: <[EMAIL PROTECTED]>
Date: Fri, 25 May 2001 20:38:49 -0700
To: <[EMAIL PROTECTED]>
Subject: broken links

http://jakarta.apache.org/tomcat/tomcat-3.2-doc/mod_jk-howto.html
http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/index.html

regs.,

Garrey Learmonth
Cisco Systems Inc.

-- End of Forwarded Message




Re: Jasper performance/3.3 tag pooling

2001-05-26 Thread Rickard Oberg

> Thanks for sending the test application.  I've been using monthlist.jsp
while
> testing rendered then hand bashed code.  After some preliminary bashing :)
> I think it will be possible to call all setters (except runtime
expressions)
> only once per run of the page.  Also, we can create / obtain tag handler
instances
> only once per page run.

That is an excellent start!

> Anyway... after tweaking the rendered code, I was disappointed that there
> wasn't much of a change in the performance when I hit the page directly.
> The "optimized" version was even a bit slower :(  So, I hooked it up to a
> profiler.  It said that most of the time was being spent in
> webwork.util.ValueStack.findValue which is called from some of
> the setters and some of the do[Start|End]Tag methods.

Yeah, it's the by far most used method, and also where most of the magic
happens (name->value conversions). I've been tweaking it some, but probably
not enough.

> So, Is there any way you could send me a new webwork.jar (no need for the
> whole .war) that has tag implementations optimized for tag instance and
> setter call reuse?.  If you can move some/many of the calls to
ValueStack.findValue
> out of the doStart/doEnd methods, that should help.

I will start working on this after the weekend. However I am also rewriting
most of the tags for a new and simpler syntax, which is going to take some
coding time too, since all the examples need to be modified, docs, etc. I
will let you know as soon as possible though when the opts. are done.

> Yes, I know this doesn't solve the problem of why weblogic was faster
> for you, but any tag related optimizations we can make should help other
> tag users (me and my day job included).

Yup, that was the basic idea when I started this thread :-) Glad to see
things happen! :-)

> If you send a new jar, I'll test it out and let you know.

Will do.

/Rickard