Peter Huber wrote:
> Hi you all,
>
> I'm new to the list maybe this stuff has been discussed several times.
> If so I'm sorry to waist your time!
>
> My point:
> tomcat 3.2 compiles a JSP into a servlet which contains out.write()
> calls which have ""-strings as arguments. As far as I understand Java,
> each ""-string creates a new Object! Therefore each out.write() creates
> a new object and this is true for each call to _jspService of the same
> object. So many calls to one and the same page result in many more
> objects.
>
> So my proposal is to compile JSP ""-strings to something like:
>
> class xyz {
> static final String arr[] = { "uvw", "abc" ... };
>
> _jspService(...) {
> ...
> out.write(arr[234])
> ...
> }
> }
>
> Peter
> --
Well, any given page creates only one instance of the servlet class, so using
static really would not make any difference here. The string constants are (in
effect) created when the class is first loaded, not on every method call. Also,
most JVMs implement String constants in a manner that they are shared across
classes and instances anyway, although there are no guarantees here.
But people who want to work on improving the quality of the code generated by
Jasper are quite welcome -- in the Tomcat 4.1 time frame, I would like to see a
lot of attention on this particular area.
Craig