Re: jasper package

2002-08-20 Thread Yunfeng Hou

> The Java compiler used by Tomcat doesn't have any
> problems compiling the
> sources that are currently being generated.  What
> compiler are you trying
> to use that has problems with it?  That's where your
> problem really
> appears to lie.
> 

Yes, because the magic class loader has the tricky
work done. Still, the package name of the generated
class and the directory it resides are not consistent.
It makes debug impossible. Here's what Sysdeo - a
tomcat plugin for eclipse, says how to debug jsp.

(http://www.sysdeo.com/eclipse/tomcatPlugin.html)

Workaround 1 : install our Tomcat 4.x patch. 
Workaround 2 (from Gabriel Krupa) : if your jsp is
/myjspdir/myjsp.jsp, generated servlet will be in
work/org/apache/jsp/myjspdir, change package
definition from org.apache.jsp to
org.apache.jsp.myjspdir, to debug your jsp access it
from your browser with the following URL :
http://myhost:8080/myapplication/servlets/org.apache.jsp.myjspdir.myjsp$jsp

Workaround 3 : use Tomcat 3.3 (servlet 2.2 and JSP
1.1), with Tomcat 3, package definition is compliant
with file location.


Yunfeng Hou

_
Do You Yahoo!? 
ÐÂÏʵ½µ×,ÓéÀÖµ½¼Ò - ÑÅ»¢ÍƳöÃâ·ÑÓéÀÖµç×ÓÖܱ¨!
http://cn.ent.yahoo.com/newsletter/index.html

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: jasper package

2002-08-20 Thread Yunfeng Hou

> The compiler driver and classloader used by tomcat
> does a lot of magic to
> get it to work. All jsp files named, for example,

Yes I know the class loader has the job done, is it
bearking the convention? Anyway, I can debug my jsp
now with the jasper I patched.

Yunfeng Hou

_
Do You Yahoo!? 
ÐÂÏʵ½µ×,ÓéÀÖµ½¼Ò - ÑÅ»¢ÍƳöÃâ·ÑÓéÀÖµç×ÓÖܱ¨!
http://cn.ent.yahoo.com/newsletter/index.html

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: jasper package

2002-08-19 Thread Steve Downey

The compiler driver and classloader used by tomcat does a lot of magic to
get it to work. All jsp files named, for example, index.jsp, will be
compiled to a class named org.apache.jsp.index$jsp.java. It will be in a
directory with the same name as the directory of the jsp file, but that's
not represented in the package name.

The classloader knows where the class file will reside, and then strips out
everything but the filename part of the URI, prepends org.apache.jsp to it,
and loads that class.

The base VM classloader CAN NOT load the generated class files. So debugging
with an IDE that doesn't have special hacks is a bit difficult. Even if you
can convince it to load servlets and debug that code, convincing it to set a
breakpoint in some class named org.apache.jsp.index$jsp, and leaving it to
figure out which one, is usually impossible.

Unless things have changed recently, then go ahead and ignore all this. I
know this applied for 4.0.3.

> -Original Message-
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 20, 2002 1:28 AM
> To: Tomcat Developers List
> Subject: Re: jasper package
> 
> 
> 
> 
> On Tue, 20 Aug 2002, [gb2312] Yunfeng Hou wrote:
> 
> > Date: Tue, 20 Aug 2002 13:13:14 +0800 (CST)
> > From: "[gb2312] Yunfeng Hou" <[EMAIL PROTECTED]>
> > Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> > To: Tomcat Developers List <[EMAIL PROTECTED]>
> > Subject: Re: jasper package
> >
> > > A desire to do this in the first place probably
> > > comes from wanting to use
> > > unpackaged classes without importing them -- which
> > > is both against the JSP
> > > spec and is also frowned on in general by the Java
> > > compiler in JDK 1.4 and
> > > later.  You're MUCH better off putting your classes
> >
> > No, I want this because I need it to debug my
> > generated class file at runtime. Currently, jasper
> > will always generate class in org.apache.jsp. For
> > example, /abc/test.jsp will have class in
> > $scratchDir/abc, and /abc/def/test.jsp will be
> > generated in $scratchDir/abc/def, with the same
> > package - org.apache.jsp! I can not even compile these
> > classes, do you think it a good design?
> >
> > Or, what I need is compile and debug, I do not need
> > that flexibility to specify package name, at least, I
> > think jasper should support this: these jsps will have
> > package name org.apache.jsp.abc and
> > org.apache.jsp.abc.def respectively.
> >
> 
> The Java compiler used by Tomcat doesn't have any problems compiling the
> sources that are currently being generated.  What compiler are you trying
> to use that has problems with it?  That's where your problem really
> appears to lie.
> 
> >
> > Yunfeng Hou
> >
> 
> Craig
> 
> 
> --
> 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]>


RE: jasper package

2002-08-19 Thread Steve Downey

For the command line compiler, I've found it very useful. It specifies the
base package for the compiled jsp pages. By matching that with the directory
that the pages are output into, I can then point an ant javac task at them
and validate that everything compiles correctly, as part of an automated
build.

That is, /index.jsp would go into
${output}/com/netfolio/compiled_jsp/index.java, and /dir/index.jsp would go
into ${output}/com/netfolio/compiled_jsp/dir/index.java. So compiling them
is just a matter of a plain compile of the ${output} directory.

When JspC is working, that is. Haven't checked recently, but it's been
broken as often as not.

The runtime jsp compiler produces, or used to produce, java files that
aren't suitable for compiling as a batch. The package didn't match up with
the directory name. It simplified class reloading, IIRC, though.


> -Original Message-
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 19, 2002 6:11 PM
> To: Tomcat Developers List
> Subject: Re: jasper package
>
>
>
>
> On Mon, 19 Aug 2002, [gb2312] Yunfeng Hou wrote:
>
> > Date: Mon, 19 Aug 2002 11:35:17 +0800 (CST)
> > From: "[gb2312] Yunfeng Hou" <[EMAIL PROTECTED]>
> > Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: jasper package
> >
> > Jasper has command line option to set package name,
> > but not true for JspServlet, I made some change to
> > give user a chance to set the packageName in the
> > servlet init parameter.
> >
>
> Personally, I think supporting this at all is a *really* bad idea ... the
> JSP spec is very clear that the container is free to put the generated
> classes in whatever package it wants to (even different ones for different
> pages), so it seems very counter-productive to allow a user to tie
> themselves to a particular version of the JSP page compiler on a
> particular container that happens to implement this kind of option.
>
> A desire to do this in the first place probably comes from wanting to use
> unpackaged classes without importing them -- which is both against the JSP
> spec and is also frowned on in general by the Java compiler in JDK 1.4 and
> later.  You're MUCH better off putting your classes into packages and
> explicitly importing them.
>
> Craig McClanahan
>
>
> --
> 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]>




Re: jasper package

2002-08-19 Thread Craig R. McClanahan



On Tue, 20 Aug 2002, [gb2312] Yunfeng Hou wrote:

> Date: Tue, 20 Aug 2002 13:13:14 +0800 (CST)
> From: "[gb2312] Yunfeng Hou" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: Tomcat Developers List <[EMAIL PROTECTED]>
> Subject: Re: jasper package
>
> > A desire to do this in the first place probably
> > comes from wanting to use
> > unpackaged classes without importing them -- which
> > is both against the JSP
> > spec and is also frowned on in general by the Java
> > compiler in JDK 1.4 and
> > later.  You're MUCH better off putting your classes
>
> No, I want this because I need it to debug my
> generated class file at runtime. Currently, jasper
> will always generate class in org.apache.jsp. For
> example, /abc/test.jsp will have class in
> $scratchDir/abc, and /abc/def/test.jsp will be
> generated in $scratchDir/abc/def, with the same
> package - org.apache.jsp! I can not even compile these
> classes, do you think it a good design?
>
> Or, what I need is compile and debug, I do not need
> that flexibility to specify package name, at least, I
> think jasper should support this: these jsps will have
> package name org.apache.jsp.abc and
> org.apache.jsp.abc.def respectively.
>

The Java compiler used by Tomcat doesn't have any problems compiling the
sources that are currently being generated.  What compiler are you trying
to use that has problems with it?  That's where your problem really
appears to lie.

>
> Yunfeng Hou
>

Craig


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




Re: jasper package

2002-08-19 Thread Yunfeng Hou

> A desire to do this in the first place probably
> comes from wanting to use
> unpackaged classes without importing them -- which
> is both against the JSP
> spec and is also frowned on in general by the Java
> compiler in JDK 1.4 and
> later.  You're MUCH better off putting your classes

No, I want this because I need it to debug my
generated class file at runtime. Currently, jasper
will always generate class in org.apache.jsp. For
example, /abc/test.jsp will have class in
$scratchDir/abc, and /abc/def/test.jsp will be
generated in $scratchDir/abc/def, with the same
package - org.apache.jsp! I can not even compile these
classes, do you think it a good design?

Or, what I need is compile and debug, I do not need
that flexibility to specify package name, at least, I
think jasper should support this: these jsps will have
package name org.apache.jsp.abc and
org.apache.jsp.abc.def respectively.


Yunfeng Hou

_
Do You Yahoo!? 
ÐÂÏʵ½µ×,ÓéÀÖµ½¼Ò - ÑÅ»¢ÍƳöÃâ·ÑÓéÀÖµç×ÓÖܱ¨!
http://cn.ent.yahoo.com/newsletter/index.html

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: jasper package

2002-08-19 Thread Craig R. McClanahan



On Mon, 19 Aug 2002, [gb2312] Yunfeng Hou wrote:

> Date: Mon, 19 Aug 2002 11:35:17 +0800 (CST)
> From: "[gb2312] Yunfeng Hou" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: jasper package
>
> Jasper has command line option to set package name,
> but not true for JspServlet, I made some change to
> give user a chance to set the packageName in the
> servlet init parameter.
>

Personally, I think supporting this at all is a *really* bad idea ... the
JSP spec is very clear that the container is free to put the generated
classes in whatever package it wants to (even different ones for different
pages), so it seems very counter-productive to allow a user to tie
themselves to a particular version of the JSP page compiler on a
particular container that happens to implement this kind of option.

A desire to do this in the first place probably comes from wanting to use
unpackaged classes without importing them -- which is both against the JSP
spec and is also frowned on in general by the Java compiler in JDK 1.4 and
later.  You're MUCH better off putting your classes into packages and
explicitly importing them.

Craig McClanahan


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




jasper package

2002-08-19 Thread Yunfeng Hou

Jasper has command line option to set package name,
but not true for JspServlet, I made some change to
give user a chance to set the packageName in the
servlet init parameter.

What I have done is add getPackageName to Options
class, modify JspServlet and ClassLoader to recognize
this parameter, remove the hard-coded default package
name Constants.JSP_PACKAGE_NAME.

diff  ./embededservletoptions.java
\Jetty-4.1.0RC1\src\org\apache\jasper/embededservletoptions.java
81,83d80
<   
<   /* the package name of the jsp class generated */
<   public String packageName =
Constants.JSP_PACKAGE_NAME;
350,354d346
< 
< String tmpStr =
config.getInitParameter("packageName");
< if (tmpStr != null && ! "".equals(tmpStr)) {
<   packageName = tmpStr;
< }
360,366d351
<   /**
<* @see org.apache.jasper.Options#getPackageName()
<*/
<   public String getPackageName() {
<   return packageName;
<   }
< 
diff  ./jspc.java
\Jetty-4.1.0RC1\src\org\apache\jasper/jspc.java
753,759d752
<   /**
<* @see org.apache.jasper.Options#getPackageName()
<*/
<   public String getPackageName() {
<   return targetPackage;
<   }
< 
diff  ./options.java
\Jetty-4.1.0RC1\src\org\apache\jasper/options.java
150,155d149
< 
< /**
<  * Package name of generated class.
<  */
< public String getPackageName();
< 

diff  ./jasperloader.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jasperloader.java
191,206c191,202
<   //if( !name.startsWith(Constants.JSP_PACKAGE_NAME)
) {
<   try {
<   ClassLoader classLoader = null;
<   if (System.getSecurityManager() != null) {
   if( !name.startsWith(Constants.JSP_PACKAGE_NAME) )
{
> ClassLoader classLoader = null;
>   if (System.getSecurityManager() != null) {
>  classLoader =
(ClassLoader)AccessController.doPrivileged(privLoadClass);
> } else {
>   classLoader =
Thread.currentThread().getContextClassLoader();
> }
> clazz = classLoader.loadClass(name);
>   if( resolve )
>   resolveClass(clazz);
>   return clazz;
>   }
209,210c205,207
<   //if( name.startsWith(Constants.JSP_PACKAGE_NAME)
&& name.endsWith(className) ) {
<   String classFile =
name.substring(name.lastIndexOf(".") + 1) + ".class";
---
>   if( name.startsWith(Constants.JSP_PACKAGE_NAME +
"." + className) ) {
>   String classFile =
name.substring(Constants.JSP_PACKAGE_NAME.length()+1)
+
>   ".class";
226c223
<   //}
---
>   }
diff  ./jspservlet.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jspservlet.java
127d126
<   
249,251d247
<   /* added by houyunf to provide package support */
<   private String packagePath = "";
< 
270,275c266
<   
<   /* added by houyunf to support package name */
<   packagePath = options.getPackageName();
<   packagePath = packagePath.replace('.', '/');
<   
<   
---
> 
348,349c339
<   String basePackage = 
options.getPackageName()+".";   // modified by houyunf
< //"org.apache.jasper.";
---
>   String basePackage = "org.apache.jasper.";
533,537d522
< String jspPackage = jspUri.substring(0,
jspUri.lastIndexOf("/"));
< if ("".equals(jspPackage))
<   jspPackage = null;
< if (jspPackage != null ) 
<   jspPackage =
jspPackage.substring(1).replace('/', '.');
542c527
< outURI = outURI + packagePath;
---
> outURI = outURI +
jspUri.substring(1,jspUri.lastIndexOf("/")+1);
544,545c529
<   outURI = outURI + "/" + packagePath;
< outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);
---
> outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);;
559,565d542
< String packageName =
options.getPackageName();
< if (packageName == null ||
"".equals(packageName)) 
<   packageName = jspPackage;
< else if (jspPackage != null)
<   packageName = packageName + "." +
jspPackag

jasper package

2002-08-18 Thread Yunfeng Hou

Jasper has command line option to set package name,
but not true for JspServlet, I made some change to
give user a chance to set the packageName in the
servlet init parameter.

What I have done is add getPackageName to Options
class, modify JspServlet and ClassLoader to recognize
this parameter, remove the hard-coded default package
name Constants.JSP_PACKAGE_NAME.

diff  ./embededservletoptions.java
\Jetty-4.1.0RC1\src\org\apache\jasper/embededservletoptions.java
81,83d80
<   
<   /* the package name of the jsp class generated */
<   public String packageName =
Constants.JSP_PACKAGE_NAME;
350,354d346
< 
< String tmpStr =
config.getInitParameter("packageName");
< if (tmpStr != null && ! "".equals(tmpStr)) {
<   packageName = tmpStr;
< }
360,366d351
<   /**
<* @see org.apache.jasper.Options#getPackageName()
<*/
<   public String getPackageName() {
<   return packageName;
<   }
< 
diff  ./jspc.java
\Jetty-4.1.0RC1\src\org\apache\jasper/jspc.java
753,759d752
<   /**
<* @see org.apache.jasper.Options#getPackageName()
<*/
<   public String getPackageName() {
<   return targetPackage;
<   }
< 
diff  ./options.java
\Jetty-4.1.0RC1\src\org\apache\jasper/options.java
150,155d149
< 
< /**
<  * Package name of generated class.
<  */
< public String getPackageName();
< 

diff  ./jasperloader.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jasperloader.java
191,206c191,202
<   //if( !name.startsWith(Constants.JSP_PACKAGE_NAME)
) {
<   try {
<   ClassLoader classLoader = null;
<   if (System.getSecurityManager() != null) {
   if( !name.startsWith(Constants.JSP_PACKAGE_NAME) )
{
> ClassLoader classLoader = null;
>   if (System.getSecurityManager() != null) {
>  classLoader =
(ClassLoader)AccessController.doPrivileged(privLoadClass);
> } else {
>   classLoader =
Thread.currentThread().getContextClassLoader();
> }
> clazz = classLoader.loadClass(name);
>   if( resolve )
>   resolveClass(clazz);
>   return clazz;
>   }
209,210c205,207
<   //if( name.startsWith(Constants.JSP_PACKAGE_NAME)
&& name.endsWith(className) ) {
<   String classFile =
name.substring(name.lastIndexOf(".") + 1) + ".class";
---
>   if( name.startsWith(Constants.JSP_PACKAGE_NAME +
"." + className) ) {
>   String classFile =
name.substring(Constants.JSP_PACKAGE_NAME.length()+1)
+
>   ".class";
226c223
<   //}
---
>   }
diff  ./jspservlet.java
\Jetty-4.1.0RC1\src\org\apache\jasper\servlet/jspservlet.java
127d126
<   
249,251d247
<   /* added by houyunf to provide package support */
<   private String packagePath = "";
< 
270,275c266
<   
<   /* added by houyunf to support package name */
<   packagePath = options.getPackageName();
<   packagePath = packagePath.replace('.', '/');
<   
<   
---
> 
348,349c339
<   String basePackage = 
options.getPackageName()+".";   // modified by houyunf
< //"org.apache.jasper.";
---
>   String basePackage = "org.apache.jasper.";
533,537d522
< String jspPackage = jspUri.substring(0,
jspUri.lastIndexOf("/"));
< if ("".equals(jspPackage))
<   jspPackage = null;
< if (jspPackage != null ) 
<   jspPackage =
jspPackage.substring(1).replace('/', '.');
542c527
< outURI = outURI + packagePath;
---
> outURI = outURI +
jspUri.substring(1,jspUri.lastIndexOf("/")+1);
544,545c529
<   outURI = outURI + "/" + packagePath;
< outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);
---
> outURI = outURI +
jspUri.substring(0,jspUri.lastIndexOf("/")+1);;
559,565d542
< String packageName =
options.getPackageName();
< if (packageName == null ||
"".equals(packageName)) 
<   packageName = jspPackage;
< else if (jspPackage != null)
<   packageName = packageName + "." +
jspPackag