You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Tal Dayan <ta...@zapta.com> on 2001/01/16 09:40:34 UTC

Proposed name encoding patch

Hello,

This is my first posting to this list so please bare with me.

We are having problems with the jsp name mangling (bug 330 at
http://znutar.cortexity.com/BugRatViewer/ShowReport/330).

Every '/' or '_' char in the jsp path is converted to 6 chars which easily
extend the file path beyond Win NT limitation of 256 chars. As a result, the
JSP compilation fails with the following error:

org.apache.jasper.JasperException: Unable to compile class for JSPerror:
Can't write:

D:\tomcat\appserv\work\localhost_8080\system\admin\modes\start\account\_0002
fsystem_0002fadmin_0002fmodes_0002fstart_0002faccount_0002fpage_0005fadmin_0
005fstart_0005faccount_0005fpassword_0002ejsppage_0005fadmin_0005fstart_0005
faccount_0005fpassword_jsp_0.class

A quick look at the code reveals that the mangling is done by the method
CommandLineCompiler.mangleChar() so we plan to modify the method to generate
a more compact encoding, especially for common chars such as '/', '_', and
'.'.

What is the view of the list regarding the proposed modification and how
should we proceed to maximize the changes that our patch will be included in
the official Tomcat code ?

Thanks,

Tal


should I worry - mod_jk problem?

Posted by Filip Hanik <fi...@filip.net>.
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (596)]: ajpv12_handle_response, error writing back to
server
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (585)]: ajpv12_handle_response, error reading from
[jk_ajp12_worker.c (596)]: ajpv12_handle_response, error writing back to
server

Is this something to be worried about, any idea on what would be causing
this?

Filip

~
Namaste - I bow to the divine in you.
~
Filip Hanik
Technical Architect
filip@filip.net

----- Original Message -----
From: <cm...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, January 16, 2001 11:39 AM
Subject: Re: Proposed name encoding patch


It's worth to mention that both JSP encoding and work dir encoding are
resolved/improved in 3.3 - and the code can be easily ported back /
reused.

I'll take a look at both patches and try to integrate them into 3.3 also (
what is not covered already )

--
Costin


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


RE: Proposed name encoding patch

Posted by Tal Dayan <ta...@zapta.com>.
Hi Costin,

I looked at the code at (one long line)

http://jakarta.apache.org/cvsweb/index.cgi/jakarta-tomcat/src/share/org/apac
he/jasper/compiler/CommandLineCompiler.java?rev=1.6&content-type=text/vnd.vi
ewcvs-markup

The mangleChar() method seems to have the old code that encodes as _xxxxx
where x
is an hex digit. If I understand the code correctly, this is where we need
to make the patch.

If this is solved somewhere else, please send me pointer so I can give it a
try.

In case we need to write a new encoding method, here are some possible
requirements, I am not sure which of them are relevant and which are not.

1. The encoding of any path should be unique.
2. The file name without the '.class' extension) should be a valid Java
class name.
3. The encoding should be intuitive.
4. The encoding should be compact, at least for common chars.
5. The encoding should support JSP name with Unicode chars.
6. Runtime efficiency. The current encoding for example creates 3 object for
each mangled char.

Any comment from members of the list will be greatly appreciated.

Tal




> -----Original Message-----
> From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> Sent: Tuesday, January 16, 2001 11:40 AM
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Proposed name encoding patch
>
>
> It's worth to mention that both JSP encoding and work dir encoding are
> resolved/improved in 3.3 - and the code can be easily ported back /
> reused.
>
> I'll take a look at both patches and try to integrate them into 3.3 also (
> what is not covered already )
>
> --
> Costin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>


Patch for bug 330

Posted by Tal Dayan <ta...@zapta.com>.
Hi Costin,

Here is our patch for bug 330,  Priority: high, Severity
serious.(http://znutar.cortexity.com/BugRatViewer/ShowReport/330).

Having this patch included the official release of 3.X.X will make Tomcat
usable for us since we could not port our application from WebSphere to
Tomcat 3.2.1 because of this problem.

To apply the patch, all you need to do is to replace the method mangleChar()
in JspCompiler.java with the new code that is included at the end of this
message.

BTW, the file CommandLineCompiler also has a similar mangleChar() method. I
am not sure when this is used but you may want to consolidate the two.

The new encoding has two forms, a short one and a general one. The short one
is used for few common chars such as '_' and '/' and '/'. This encoding maps
into a two char string of the form '_' <l> where <l> is a non hex char (g-z)
(e.g. '_' --> '__', '.' --> '_p' etc). It is a more compact, 'readable'
(e.g. the 'p' in '.'-->'_p' stands for 'period') and is more efficient since
it does not create any object.

The general form is used for the rest of the chars, including Unicode's. It
is of variable length and for most of the common chars (e.g. ASCII) it will
result in a shorter encoding than the one currently used. This encoding uses
the form '_' <hex-rep> 'x' where <hex_rep> is a variable length hex
representation of the numeric value of the char (e.g. "_f4x", "_123ax").

Please review the patch and 'squeeze' it to the next maintenance release of
3.X.X.

Thanks,

Tal



-------- new code ------

    /*
     * Encode special chars using a representation that contains only
     * simple chars that can be used in class names (digits, letters,
     * and '_').
     */
    private static final String mangleChar(char ch) {

        if(ch == File.separatorChar) {
	    ch = '/';
	  }

        /*
         * Use a compact and more readable encoding for few common chars.
         *
         * Note: the char we append after the '_' should not be hex digit
         * to avoid ambiguity with the general encoding we perform for the
rest of
         * the chars.
         */
        if (ch == '_')
        {
          return "__";  // underscore
        }

        if (ch == '-')
        {
          return "_m";  // minus
        }

        if (ch == '.')
        {
          return "_p";  // period
        }

        if (ch == '/')
        {
          return "_s";  // seperator
        }

        /*
         * Encode the general case. We encode the char as follows
         *
         * '_' <hex-rep> 'x'
         *
         * Where h is <hex-rep> is a variable length Hexadecimal
         * represnetation of the numeric value
         * of the char as returned by IntegertoHexString().
         */
        return "_" + Integer.toHexString(ch) + "x";
    }

-------- old code

    private static final String mangleChar(char ch) {

        if(ch == File.separatorChar) {
	    ch = '/';
	}
	String s = Integer.toHexString(ch);
	int nzeros = 5 - s.length();
	char[] result = new char[6];
	result[0] = '_';
	for (int i = 1; i <= nzeros; i++)
	    result[i] = '0';
	for (int i = nzeros+1, j = 0; i < 6; i++, j++)
	    result[i] = s.charAt(j);
	return new String(result);
    }


> -----Original Message-----
> From: cmanolache@yahoo.com [mailto:cmanolache@yahoo.com]
> Sent: Tuesday, January 16, 2001 11:40 AM
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Proposed name encoding patch
>
>
> It's worth to mention that both JSP encoding and work dir encoding are
> resolved/improved in 3.3 - and the code can be easily ported back /
> reused.
>
> I'll take a look at both patches and try to integrate them into 3.3 also (
> what is not covered already )
>
> --
> Costin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>


Re: Proposed name encoding patch

Posted by cm...@yahoo.com.
It's worth to mention that both JSP encoding and work dir encoding are
resolved/improved in 3.3 - and the code can be easily ported back /
reused. 

I'll take a look at both patches and try to integrate them into 3.3 also (
what is not covered already ) 

-- 
Costin


RE: Proposed name encoding patch

Posted by Tal Dayan <ta...@zapta.com>.
Hi Kim,

That's great. I have few questions:

1. Have you submitted the patch to the Tomcat repository ? If so,
do you know in what version it will be released ?

2. Also, the encoding that you use is of the form %hh where 'hh' is an hex
value. I had the implression that for public classes, the .class file name
should match the file name. Don't you have a problem with that (since a
class name cannot contain '%') ?

3. In what part of the code did you made the change, was it in mangleChar()
method ?

Thanks

Tal

> -----Original Message-----
> From: Pilho Kim [mailto:phkim@math.soongsil.ac.kr]
> Sent: Tuesday, January 16, 2001 11:06 AM
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: Proposed name encoding patch
>
>
> Hi, Tal
>
> I have ever solved the problem already.
> Try to check
> http://w4.metronet.com/~wjm/tomcat/2000/Aug/msg00595.html
>
> Thanks,
> Kim
>
>
> On Tue, 16 Jan 2001, Tal Dayan wrote:
>
> > Hello,
> >
> > This is my first posting to this list so please bare with me.
> >
> > We are having problems with the jsp name mangling (bug 330 at
> > http://znutar.cortexity.com/BugRatViewer/ShowReport/330).
> >
> > Every '/' or '_' char in the jsp path is converted to 6 chars
> which easily
> > extend the file path beyond Win NT limitation of 256 chars. As
> a result, the
> > JSP compilation fails with the following error:
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSPerror:
> > Can't write:
> >
> >
> D:\tomcat\appserv\work\localhost_8080\system\admin\modes\start\acc
> ount\_0002
> >
> fsystem_0002fadmin_0002fmodes_0002fstart_0002faccount_0002fpage_00
> 05fadmin_0
> >
> 005fstart_0005faccount_0005fpassword_0002ejsppage_0005fadmin_0005f
> start_0005
> > faccount_0005fpassword_jsp_0.class
> >
> > A quick look at the code reveals that the mangling is done by the method
> > CommandLineCompiler.mangleChar() so we plan to modify the
> method to generate
> > a more compact encoding, especially for common chars such as
> '/', '_', and
> > '.'.
> >
> > What is the view of the list regarding the proposed modification and how
> > should we proceed to maximize the changes that our patch will
> be included in
> > the official Tomcat code ?
> >
> > Thanks,
> >
> > Tal
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, email: tomcat-dev-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
>
>


Re: Proposed name encoding patch

Posted by Pilho Kim <ph...@math.soongsil.ac.kr>.
Hi, Tal

I have ever solved the problem already.
Try to check
http://w4.metronet.com/~wjm/tomcat/2000/Aug/msg00595.html

Thanks,
Kim


On Tue, 16 Jan 2001, Tal Dayan wrote:

> Hello,
> 
> This is my first posting to this list so please bare with me.
> 
> We are having problems with the jsp name mangling (bug 330 at
> http://znutar.cortexity.com/BugRatViewer/ShowReport/330).
> 
> Every '/' or '_' char in the jsp path is converted to 6 chars which easily
> extend the file path beyond Win NT limitation of 256 chars. As a result, the
> JSP compilation fails with the following error:
> 
> org.apache.jasper.JasperException: Unable to compile class for JSPerror:
> Can't write:
> 
> D:\tomcat\appserv\work\localhost_8080\system\admin\modes\start\account\_0002
> fsystem_0002fadmin_0002fmodes_0002fstart_0002faccount_0002fpage_0005fadmin_0
> 005fstart_0005faccount_0005fpassword_0002ejsppage_0005fadmin_0005fstart_0005
> faccount_0005fpassword_jsp_0.class
> 
> A quick look at the code reveals that the mangling is done by the method
> CommandLineCompiler.mangleChar() so we plan to modify the method to generate
> a more compact encoding, especially for common chars such as '/', '_', and
> '.'.
> 
> What is the view of the list regarding the proposed modification and how
> should we proceed to maximize the changes that our patch will be included in
> the official Tomcat code ?
> 
> Thanks,
> 
> Tal
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org
> 
>