You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mike <Kr...@wanari.com> on 2001/09/28 17:53:32 UTC

Jasper compiler BUG ???

Hello..

I have found a strange compiler behavior when I moved my project from
Servletexec engine to Jakarta-Tomcat-4.0, and I think it could be a BUG.

Here is my simplifed JSP source code:

<%session.invalidate();%>
<jsp:useBean id="oHashtable" class="java.util.Hashtable" scope="session"/>

The problem around the generated java code. Here is the Jasper generated
code:

                session.invalidate();
                java.util.Hashtable oHashtable = null;
                boolean _jspx_specialoHashtable  = false;
                 synchronized (session) {
                    oHashtable= (java.util.Hashtable)

pageContext.getAttribute("oHashtable",PageContext.SESSION_SCOPE);
                    if ( oHashtable == null ) {
                        _jspx_specialoHashtable = true;
                        try {
                            oHashtable = (java.util.Hashtable)
Beans.instantiate(this.getClass().getClassLoader(), "java.util.Hashtable");
                        } catch (Exception exc) {
                             throw new ServletException (" Cannot create
bean of class "+"java.util.Hashtable");
                        }
                        pageContext.setAttribute("oHashtable", oHashtable,
PageContext.SESSION_SCOPE);
                    }
                 }
                if(_jspx_specialoHashtable == true) {
                }

And here is the Servletexec generated code:

        session.invalidate();
        java.util.Hashtable oHashtable =
(java.util.Hashtable)session.getAttribute( "oHashtable" );
        if ( oHashtable == null )
        {
            synchronized ( session )
            {
                oHashtable =
java.util.Hashtable)session.getAttribute( "oHashtable " );
                if ( oHashtable == null )
                {
                    oHashtable = (java.util.Hashtable)new
java.util.Hashtable();
                    session.setAttribute( "oHashtable ", oHashtable );
                }
            }
        }

Oke, you can spot the difference. Check the getAttribute and setAttribute
functions.The Jasper version works with the pageContext object and the
Servletexec works with the session object, which one is the correct
implementation ???

The real problem is, the Jasper version throws an Exception on getAttribute
method, and with other engines (JRUN, Servletexec, Jaguar) it works
perfectly.

Any suggestion ??

Mike

Krautheim Mihály, Wanari Ltd.
www.wanari.com







Re: Jasper compiler BUG ???

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 28 Sep 2001, Mike wrote:

> Date: Fri, 28 Sep 2001 17:53:32 +0200
> From: Mike <Kr...@wanari.com>
> Reply-To: tomcat-dev@jakarta.apache.org
> To: tomcat-dev@jakarta.apache.org
> Subject: Jasper compiler BUG ???
>
> Hello..
>
> I have found a strange compiler behavior when I moved my project from
> Servletexec engine to Jakarta-Tomcat-4.0, and I think it could be a BUG.
>
> Here is my simplifed JSP source code:
>
> <%session.invalidate();%>
> <jsp:useBean id="oHashtable" class="java.util.Hashtable" scope="session"/>
>
> The problem around the generated java code. Here is the Jasper generated
> code:
>
>                 session.invalidate();
>                 java.util.Hashtable oHashtable = null;
>                 boolean _jspx_specialoHashtable  = false;
>                  synchronized (session) {
>                     oHashtable= (java.util.Hashtable)
>
> pageContext.getAttribute("oHashtable",PageContext.SESSION_SCOPE);
>                     if ( oHashtable == null ) {
>                         _jspx_specialoHashtable = true;
>                         try {
>                             oHashtable = (java.util.Hashtable)
> Beans.instantiate(this.getClass().getClassLoader(), "java.util.Hashtable");
>                         } catch (Exception exc) {
>                              throw new ServletException (" Cannot create
> bean of class "+"java.util.Hashtable");
>                         }
>                         pageContext.setAttribute("oHashtable", oHashtable,
> PageContext.SESSION_SCOPE);
>                     }
>                  }
>                 if(_jspx_specialoHashtable == true) {
>                 }
>
> And here is the Servletexec generated code:
>
>         session.invalidate();
>         java.util.Hashtable oHashtable =
> (java.util.Hashtable)session.getAttribute( "oHashtable" );
>         if ( oHashtable == null )
>         {
>             synchronized ( session )
>             {
>                 oHashtable =
> java.util.Hashtable)session.getAttribute( "oHashtable " );
>                 if ( oHashtable == null )
>                 {
>                     oHashtable = (java.util.Hashtable)new
> java.util.Hashtable();
>                     session.setAttribute( "oHashtable ", oHashtable );
>                 }
>             }
>         }
>
> Oke, you can spot the difference. Check the getAttribute and setAttribute
> functions.The Jasper version works with the pageContext object and the
> Servletexec works with the session object, which one is the correct
> implementation ???
>
> The real problem is, the Jasper version throws an Exception on getAttribute
> method, and with other engines (JRUN, Servletexec, Jaguar) it works
> perfectly.
>
> Any suggestion ??
>
> Mike
>
> Krautheim Mihály, Wanari Ltd.
> www.wanari.com
>

Either implementation is entirely legal, as long as all the semantic
requirements of the PageContext class are obeyed.  Implementations are
free to do what they want within the rules.

You'll need to post a stack trace (and an example piece of code
illustrating it to get any debugging help - and that discussion is better
placed on the TOMCAT-USER mailing list.

Craig McClanahan