Yes, you can have two JSP pages with the same name but in different directories
and everything will work fine even though they have the same package and class name.
This is because a custom URLClassLoader is created for each individual JSP page.
That class loader only loads the one java class for that one JSP page.

For example:

/myapp/this/hello.jsp
/muapp/that/hello.jsp

The class files will end up in:

$CATALINA_BASE/work/Standalone/localhost/myapp/this/hello.class
$CATALINA_BASE/work/Standalone/localhost/myapp/that/hello.class

Since two different URLClassLoaders are used Jasper can
load each of the above two classes even though they have
the same package and class name.

The old methods Jasper used for loading java classes generated for JSP
pages was very inefficient.  The above change simplified Jasper and
improved its performance by 25%.

Regards,

Glenn

John Trollinger wrote:
> Greg, 
> 
> I took this off of the bug tracking because it is not a bug and I
> thought there are people a lot smarter than me in this mailing list that
> could help answer you questions.  
> 
> I do not know how jasper differentiates between hello.jsp and
> /anydir/hello.jsp when the both compile to a class
> org.jasper.jsp.hello_jsp but it does work...
> 
> My hello.jsp in the root dir prints hello Jasper world and my hello.jsp
> in the subdir prints hello john world.  It works without a hitch..
> (notice that I have removed the .java files for the 2 hello world files
> and it did not regenerate them)
> 
> Here is my file list
> 
> Directory of C:\appserver\Tomcat\jspcache
> 
> 08/21/2002  02:19 PM    <DIR>          .
> 08/21/2002  02:19 PM    <DIR>          ..
> 08/21/2002  11:47 AM             3,496 date_jsp.java
> 08/21/2002  11:52 AM             2,975 hello_jsp.class
> 08/21/2002  11:51 AM             2,883 index_jsp.class
> 08/21/2002  11:51 AM             1,863 index_jsp.java
> 08/21/2002  01:27 PM    <DIR>          subdir
>                4 File(s)         11,217 bytes
> 
>  Directory of C:\appserver\Tomcat\jspcache\subdir
> 
> 08/21/2002  01:27 PM    <DIR>          .
> 08/21/2002  01:27 PM    <DIR>          ..
> 08/21/2002  11:47 AM             3,334 date2_jsp.java
> 08/21/2002  11:52 AM             2,970 hello_jsp.class
> 
> Here is my jsp.xml
> 
> <!--
> Automatically created by Tomcat JspC.
> Place this fragement in the web.xml before all icon, display-name,
> description, distributable, and context-param elements.
> -->
> 
>       <servlet>
>               <servlet-name>org.apache.jsp.date_jsp</servlet-name>
>               <servlet-class>org.apache.jsp.date_jsp</servlet-class>
>       </servlet>
> 
>       <servlet>
>               <servlet-name>org.apache.jsp.hello_jsp</servlet-name>
>               <servlet-class>org.apache.jsp.hello_jsp</servlet-class>
>       </servlet>
> 
>       <servlet>
>               <servlet-name>org.apache.jsp.date2_jsp</servlet-name>
>               <servlet-class>org.apache.jsp.date2_jsp</servlet-class>
>       </servlet>
> 
>       <servlet>
>               <servlet-name>org.apache.jsp.hello_jsp</servlet-name>
>               <servlet-class>org.apache.jsp.hello_jsp</servlet-class>
>       </servlet>
> 
>       <servlet-mapping>
>               <servlet-name>org.apache.jsp.date_jsp</servlet-name>
>               <url-pattern>/date.jsp</url-pattern>
>       </servlet-mapping>
> 
>       <servlet-mapping>
>               <servlet-name>org.apache.jsp.hello_jsp</servlet-name>
>               <url-pattern>/hello.jsp</url-pattern>
>       </servlet-mapping>
> 
>       <servlet-mapping>
>               <servlet-name>org.apache.jsp.date2_jsp</servlet-name>
>               <url-pattern>/subdir/date2.jsp</url-pattern>
>       </servlet-mapping>
> 
>       <servlet-mapping>
>               <servlet-name>org.apache.jsp.hello_jsp</servlet-name>
>               <url-pattern>/subdir/hello.jsp</url-pattern>
>       </servlet-mapping>
> 
> <!--
> All session-config, mime-mapping, welcome-file-list, error-page, taglib,
> resource-ref, security-constraint, login-config, security-role,
> env-entry, and ejb-ref elements should follow this fragment.
> -->
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to