Hi Woodchuck,

I just fought the exact same thing for two weeks and
this is what I discovered:

If you want to precompile all the JSPs with a package
name other than org.apache.jsp you have to use the -p
option and give it a new package name.  This doesn't
really work, as you may have already discovered,
especially if you want the subdirectories the JSPs
exist under to be included in the package name.  To
get the sub-dirs included I wrote a script to find all
the JSPs under my app's root dir then walked through
the list and submitted a jspc compile for each of the
JSPs in the list.  I computed the package name based
on the sub-directory the JSP was found in.  Here's the
main loop I used for my script:

# Begin Code ---------------------------------

ALL_JSP_FILES=`find ${WEBAPP_ROOT_DIR}/${PRODUCT}/*
-name '*.jsp'`
for i in ${ALL_JSP_FILES}
do
   echo "Compiling $i"

   JSP_FILE=${i##*/}
   #echo "JSP_FILE = $JSP_FILE"
  
   # JSP_DIR is just an intermediate directory that
   # doesn't need to be passed on to the next 
   # script (i.e. doesn't need to be exported).
   JSP_DIR=${i%/*}
   #echo "JSP_DIR = $JSP_DIR"

   PRODUCT_SUB_DIR=${JSP_DIR#*/${PRODUCT}}
   #echo "PRODUCT_SUB_DIR = $PRODUCT_SUB_DIR"
 
   # We have to "source" this script in order 
   # for the exported variables to still be
   # valid. (i.e. put the . in front of it)

   . compile_single_jsp.sh

done 

# End Code --------------------------------

The compile_single_jsp.sh converts the PRODUCT_SUB_DIR
variable to a dotted package name suffix using sed:

PACKAGE_SUFFIX=`echo "$PRODUCT_SUB_DIR" | sed -e
's/\//./g'`

and then calls jspc.sh to do the actual compile:

jspc.sh \
-v4 \
-l \
-compile \
-d
${TOMCAT_ROOT_DIR}/webapps/${PRODUCT}/WEB-INF/classes
\
-p com.mycompany${PACKAGE_SUFFIX} \
-webinc
${TOMCAT_ROOT_DIR}/webapps/${PRODUCT}${PRODUCT_SUB_DIR}/${JSP_FILE}.xml
\
${TOMCAT_ROOT_DIR}/webapps/${PRODUCT}${PRODUCT_SUB_DIR}/${JSP_FILE}

I run this from the /bin directory in my tomcat root. 
The downside to this is that you then have to merge
all of the individual web.xml fragments produced by
each compile into the existing web.xml (or a brand new
one you create).  I wrote another script and then a
C++ program to do this.

The only way around this is to use Tomcat 5.x to do
the compile.  It will automatically compute the
package name with subdirs though I still had to submit
each by hand to get it to compile beyond my root
directory (I'm still looking into this).  Of course
you can't run these compiled JSPs under anything but
Tomcat 5.x so it's kind of useless if you are stuck
back at 4.x.  I had to move to 5.x because of a bug in
the 4.x jspc compiler that produced 0 length .java
files on an compile error but didn't tell you what the
error was.  So currently I use jspc from Tomcat 5.0.25
but still merge all the xml fragments after the
compiles complete.  It sucks, but the code is already
written so I'm sticking with it until I have time to
find another way.

Hope that helps,
Jason

--- Woodchuck <[EMAIL PROTECTED]> wrote:
> hi,
> 
> when i pre-compile my jsps, i found that Tomcat only
> likes them when they are compiled with the package
> "org.apache.jsp".
> 
> if i change the generated *_jsp.java files (before
> compiling) to a different package that is anything
> but
> "org.apache.jsp", Tomcat fails to load them when I
> try
> to access the page.
> 
> Tomcat (4.1.x) seems to have hard-coded logic inside
> to only work with jsp class files packaged under
> org.apache.jsp.
> 
> has anyone found a workaround for this, so that we
> are
> not restricted to compile all jsp's to the package
> org.apache.jsp?
> 
> is this a setting/configuration we can tweak on
> Tomcat?
> 
> thanks in advance!!
> 
> 
>       
>               
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/ 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 



        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

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

Reply via email to