You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Catarina Reis <ca...@milu.ipn.pt> on 2000/08/23 12:45:18 UTC

Is there any file maximum name size?

Hi!

I'm trying to execute a JSP with Tomcat, but I keep getting the
following error:

"org.apache.jasper.JasperException: Unable to compile class for
JSPerror: Can't write:
C:\csis\jakarta-tomcat\work\localhost_8080%2Fcsis\jsp_00028_00032_00030_00030_00030_0002d_00030_00038_0002d_00030_00036_00029\_0002fjsp_00028_00032_00030_00030_00030_0002d_00030_00038_0002d_00030_00036_00029_0002fCustomerDataScreen_0002ejspCustomerDataScreen_jsp_0.class

1 error"

However, if I change the name of the JSP to a smaller one (ex: CDS.jsp),
it suddenly starts working.

My question is: Is there a max lenght limit to the name of the JSP
files? Is it configurable? Or is my problem other than the name of the
JSP?


best regards

Catarina Reis

php and servlet

Posted by yangyuexiang <ya...@comp.nus.edu.sg>.
Hi,

Who can give me some information about the comparison of php, perl etc with
java servlets?
I mean the futures of these techniques and their applications for the time
being.

Thanks
yang


Re: Is there any file maximum name size?

Posted by Pierre Delisle <pi...@sun.com>.
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