You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Steve Downey <st...@netfolio.com> on 2002/08/24 05:26:48 UTC

Re: [PROPOSAL] - jasper2 JspC --servlet option

OK, I believe I've tracked it down. Jasper, as opposed to Jasper2, had 
distinct Context for CommandLine and for JspEngine.  They did slightly 
different things, in particular, they treated the package name VERY 
differently.

The key difference is getServletPackageName(). This is the version from 
CommandLineContext:

    public String getServletPackageName() {
        //Get the path to the jsp file.  Note that the jspFile, by the
        //time it gets here, would have been normalized to use '/'
        //as file separator.

        int indexOfSlash = getJspFile().lastIndexOf('/');
        String pathName;
        if (indexOfSlash != -1) {
            pathName = getJspFile().substring(0, indexOfSlash);
        } else {
            pathName = "/";
        }

        //Assemble the package name from the base package name specified on
        //the command line and the package name derived from the path to
        //the jsp file
        String packageName = "";
        if (servletPackageName != null) {
            packageName = servletPackageName;
        }
        packageName += pathName.replace('/', '.');

        return CommandLineCompiler.manglePackage(packageName);
    }

This is from JspEngineContext

    public String getServletPackageName() {
        return servletPackageName;
    }


On Friday 23 August 2002 03:38 pm, jakarta@trollingers.com wrote:
> right now it only works if you do not have 2 jsp files with the
> same name, or are still going through Jaspers magic classloader
> to call the servlets.  If you want to deploy the servlets
> without the jsp pages (ie go through the default servlet) then
> if you have to jsp pages with the same name they will have the
> same class file name therefor the classloader for servlets will
> only load one of them.
>
> John
>
> > Ok, I'm confused - I thought that already works.
> >
> > I'm actually using this feature - jspc generates servlets and
> > web.xml fragments.
> >
> > Is there something missing ?
> >
> > What I use ( I already posted that ) is:
> >
> >   <target name="jspc" depends="..." >
> >     <mkdir dir="${build.dir}/src/myPackage" />
> >     <taskdef classname="org.apache.jasper.JspC" name="jasper2"
> >
> >       <classpath>
> >         <pathelement location="${java.home}/../lib/tools.jar"/>
> >         <fileset dir="${tomcat.home}/server/lib">
> >           <include name="*.jar"/>
> >         </fileset>
> >         <fileset dir="${tomcat.home}/common/lib">
> >           <include name="*.jar"/>
> >         </fileset>
> >         <pathelement location="${build.dir}/classes"/>
> >         <path refid="myjars"/>
> >       </classpath>
> >     </taskdef>
> >
> >     <jasper2 verbose="0"
> >              package="myPackage"
> >              compile="true"
> >              validateXml="false"
> >              uriroot="${my.webapp.dir}"
> >              webXmlFragment="${build.dir}/generated_web.xml"
> >               outputDir="${build.dir}/src/myPackage" />
> >
> >     <loadfile property="generated_web.xml"
> >               srcFile="${build.dir}/generated_web.xml"  />
> >     <replace file="${my.webapp.dir}/WEB-INF/web.xml"
> >              token="<!--GENERATED_JSPS-->"
> >              value="${generated_web.xml}" />
> >
> >     <javac destdir="${build.dir}/classes"
> >            optimize="off"
> >            debug="on"
> >            srcdir="${build.dir}/src" >
> >       <classpath>
> >         <pathelement location="${java.home}/../lib/tools.jar"/>
> >         <fileset dir="${tomcat.home}/server/lib">
> >           <include name="*.jar"/>
> >         </fileset>
> >         <fileset dir="${tomcat.home}/common/lib">
> >           <include name="*.jar"/>
> >         </fileset>
> >         <pathelement location="${build.dir}/classes"/>
> >         <path refid="myjars"/>
> >       </classpath>
> >       <include name="myPackage/**" />
> >     </javac>
> >
> >     <jar jarfile="${my.webapp.dir}/WEB-INF/lib/my-jsp.jar" >
> >       <fileset dir="${build.dir}/classes">
> >         <include name="myPackage/**"/>
> >       </fileset>
> >     </jar>
> >   </target>
> >
> > Costin
> >
> > On Fri, 23 Aug 2002, John Trollinger wrote:
> > > This option will compile the jsp pages with a package
>
> structure so that
>
> > > they can be deployed as servlets rather than jsp pages. (it
>
> can also be
>
> > > used with the -p option that will give it a base package
>
> name)
>
> > > /index.jsp --> <base package name>.index_jsp
> > > /subdir/index.jsp --> <base package name>.subdir.index_jsp
> > >
> > > Let me know if anyone likes this, if so I will go ahead and
>
> do the impl.
>
> > > John Trollinger
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:   <mailto:tomcat-dev-
>
> unsubscribe@jakarta.apache.org>
>
> > > For additional commands, e-mail: <mailto:tomcat-dev-
>
> help@jakarta.apache.org>
>
> > --
> > To unsubscribe, e-mail:   <mailto:tomcat-dev-
>
> unsubscribe@jakarta.apache.org>
>
> > For additional commands, e-mail: <mailto:tomcat-dev-
>
> help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>