tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Speed <psp...@progeeks.com>
Subject Re: [SSI] initial environment?
Date Tue, 04 Dec 2001 04:22:28 GMT


Brian Zhou wrote:
> 
> Hi tomcat-developers,
> 
> Is there a prefered way to set the initial env for an SSI page? I'm working
> on a simple template servlet using SSI to allow something like:
> 
> <!--#include virtual="${header}"-->
> <!--#include virtual="${body}"-->
> <!--#include virtual="${footer}"-->
> 
> Most of the support are there, but how does one set the initial env
> programatically from a servlet? I know probably I can add a
> "tomcat.ssi.environment" SsiEnvironment instance as attribute of the
> HttpServletRequest, but it seems to involve the whole catalina.jar and
> servlets-ssi.jar (and maybe more) being copied into
> servletContext/WEB-INF/lib. Is it possible we leave a light-weight,
> loosly-coupled hook for this purpose? I give an example below just using
> Hashtable, of course we can change the attribute name.
> 
> JSP and taglib can achieve the same thing, but I just like the
> non-invasiveness of SSI better - everything still in valid HTML.

That's an interesting idea.  I hadn't thought of that when I wrote 
that stuff.  The problem with using SsiEnvironment directly is, as
you noticed, that it is in the catalina class loader and relies on
at least one other catalina.jar class.  (This was true even before
my SsiEnvironment changes.)

Your code snippet below works, of course.  I'm not a committer, just
an interested party that recently refactored most of the SSI stuff as
a simple contributor ;) ... so I can't actually do anything about any
suggestions along these lines.  The only hesitation that I think a 
committer would have is that your changes are non-standard.  I'm 
pretty sure that there is no standard way to set SSI variables from 
a servlet... and certainly no pre-defined way in the SSI support in 
catalina.  My "pretty sure" also comes from the experience of looking
through the apache module to make sure the tomcat version is as 
compatable as possible.

The reason I enhanced the SSI support in the first place is because
I frequently do something similar myself.  However, in my case, 
my pages contain the body and just include the header and footer.
That way I still have unique URLs for my content... they just pull
in the standard parts from other files.  I don't know if that will
work in your case, though.

Otherwise, your custom mods are probably the only way to solve your
needs.
-Paul

> 
> Thanks,
> 
> -Brian
> 
> diff -r1.2 SsiEnvironment.java
> 69d68
> < import java.util.Date;
> 72a72,73
> > import java.util.Date;
> > import java.util.Enumeration;
> 257a259,267
> >
> >         Hashtable initialEnv = (Hashtable)
> request.getAttribute("initial.env");
> >         if (initialEnv != null) {
> >             Enumeration e = initialEnv.keys();
> >             while (e.hasMoreElements()) {
> >                 String key = (String) e.nextElement();
> >                 this.setVariable(key, (String) initialEnv.get(key));
> >             }
> >         }
> 
> --
> 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>


Mime
View raw message