tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Delisle <pierre.deli...@sun.com>
Subject Re: Is there any file maximum name size?
Date Thu, 24 Aug 2000 00:00:47 GMT
Yes indeed, the file name generated by the jsp container can be quite
long.

If you're interested to know why, please read on.
If not, use the following tips to reduce the length of the names 
generated by the jsp container:

   - Don't use special characters or digits in your filename as they
     are 'mangled' to a 6-character string

   - Put your files as close as possible to the root of your web
application
     context, since the filename is built in part from the 
     context rooted URI of the JSP file.

   - Avoid long names :-)

-----
<start-lenghty-explanation>

When processing a jsp page, the jsp container needs to map the name of
the 
JSP page into a valid java class name that is unique.

  - Valid java class names are defined in the JLS 
    (Java Language Specification) as 
      "an unlimited-length sequence of Java letters and Java digits, 
       the first of which must be a Java letter".
    [Characters like '\' and '.' are not valid.]

  - For the generated class name to be unique, 
    the container builds a prefix that is built from the 
    the context rooted URI of the JSP file. 

For example, if I access the jsp file "hello.jsp" at the root of my
application context, the prefix is built as follows:

   context rooted URI of the JSP file:  \hello.jsp
                               prefix: _0002fhello_0002ejsp

      where _0002f and _0002e are '\' and '.' respectively
      mangled to a 6 character string using Integer.toHexString().

[Why not convert invalid characters to something like '_', instead of
the 'mangled' string value? This is done so that two filenames that only
differ
with special characters at the same locations still yield unique
names (e.g. hello-1  and hello#1).]

Then after the prefix, the last component of the context rooted URI
(with the extension removed) is added. This constitutes the class name.

Finally, for the java file, a suffix of _jsp_# (where # is replaced by
a serial id) is also added (serial id required to distinguish multiple
'recompiles' on the same jsp page that's been updated).

So, for my jsp file "hello.jsp" located at the root of my app context,
this yields:
     _0002fhello_0002ejsphello.class
     _0002fhello_0002ejsphello_jsp_0.java

Also, to make things worse, if digits exist in the URI, they will
be converted also to the 6-char string in the prefix.

For file "hello2.jsp" located in the "foo" subdirectory, this yields:
     _0002ffoo_0002fhello_00032_0002ejsphello2.class
     _0002ffoo_0002fhello_00032_0002ejsphello2_jsp_0.java


So, you can very well see that if your jsp filename is located deep
into your web app context, and that you use special characters
and digits in your filename, and that you have long filenames,
this yields a _huge_ filename that may
well break the limits allowed by the underlying OS.

But all is not lost...
As you probably realized in the above description, it is possible to
have a better name mangling algorithm to reduce the length of the 
generated file/class names.
This will be done in the upcoming release of tomcat 4.0
(which will support the servlet 2.3 and JSP 1.2 specs)

    -- Pierre

Mime
View raw message