You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by William Shulman <wi...@metaconsortium.com> on 2001/06/21 05:17:29 UTC

installing struts taglibs

Hello -

I have been using the struts tablibs for a few weeks now and
integrated them with my application by adding taglib declarations in
my web.xml file to point to the struts tld files. However, I was
reading the installation notes again and noticed that another way to
install struts is to simply copy all of the struts .war files into my
webapps directory. However, it seems that I still have to modify my
web.xml file to include the struts taglibs. Is this the case or am I
doing someting wrong. I was hoping I could just copy the .war files
and be done.

-will

Re: installing struts taglibs

Posted by William Shulman <wi...@metaconsortium.com>.
thanks for the explaination.

-will

Craig R. McClanahan writes:
 > 
 > 
 > On Thu, 21 Jun 2001, William Shulman wrote:
 > 
 > > 
 > > thanks Craig-
 > > 
 > > I may be appealing to the wrong crowd (as I expect this stuff is all
 > > part of the Servlet spec), but this somehow seems to be less modular
 > > than I would like. It seems that the spirit or .war files is to be an
 > > extension of the .jar file concept, generalized to entire j2ee
 > > applications. When I obtain a .jar file for classes I would like to
 > > use -- all I need to do is place that .jar file in my CLASSPATH and I
 > > can use the classes. The analogy does not seem to fully carry over
 > > into .war files. Would it not be better if I was able to package my
 > > entrire application and supporting resources (html, xml, tld,
 > > etc.. files) and have the servlet or j2ee system know how to access
 > > all of those resources in a generic way, similar to the approach with
 > > .jar files and classes? It seems that the current approach only goes
 > > half way -- I can introduce a .war file and have the servlet container
 > > interpret its structure in some ways (making a context, recognizing
 > > the docroot, etc), but not in other ways (allowing my jsp files to
 > > import or declare taglibs contained in the .war file, or recognize classes)
 > > 
 > 
 > Well, you've certainly got most of the "self contained" stuff you are
 > after:
 > * Want to use a JAR file in your app?  Stick it into /WEB-INF/lib
 >   and it is automatically available to you.
 > * Want to access a static resource in your app?  Use
 >   ServletContext.getResource() and you don't have to care how the
 >   servlet container deals with it.
 > * Want to change the context path of your app?  The details of how
 >   to do this vary by servlet container, but it's trivially easy
 >   (especially with Struts) to make your application independent
 >   of what the actual context path is.
 > * Want to us a tag library?  Somehow, you've got to create a mapping
 >   from the URI used in your pages to the corresponding TLDs.  There
 >   are a variety of ways to do this, but I've found that explicitly
 >   referencing TLDs in the WEB-INF directory is the least confusing.
 > 
 > > Is there some design reason for this that I do not understand? It
 > > seems things could be architected such that the steps you outline
 > > below are not needed.
 > > 
 > 
 > For the separate TLD files themselves, there's a spec-related issue that
 > caused this approach.
 > 
 > The JSP 1.1 spec defines the concept of a tag library that is encapsulated
 > in a single JAR file (including the TLD, which you placed at the
 > META-INF/tablib.tld entry.  Thus, you could just drop a tab library into
 > your WEB-INF/lib directory, create a URI for it in web.xml, and go.
 > 
 > Now, originally, Struts only had one tag library, so this strategy was
 > quite useful -- stick the "struts.tld" file into struts.jar, and
 > everything was fine.  However, Struts now has four tag libraries (and the
 > number is likely to grow in the future).  But you cannot have more than
 > one encapsulated TLD in a single JAR file in JSP 1.1 -- and separating
 > struts.jar into five JAR files doesn't really help anything.
 > 
 > In JSP 1.2, this changes -- you'll be able to to encapsulate all of the
 > Struts tag libraries in struts.jar and dispense with the separate TLD
 > files.  But, until JSP 1.2 containers are widely deployed, we're stuck
 > with the 1.1 restrictions.
 > 
 > But the bottom line is that the architecture of web applications is
 > defined by the servlet spec.  Therefore, Struts has to live within those
 > rules, just like any other web application or framework based on servlets
 > will have to.
 > 
 > > -will
 > > 
 > > 
 > 
 > Craig
 > 
 > 

Re: installing struts taglibs

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 21 Jun 2001, William Shulman wrote:

> 
> thanks Craig-
> 
> I may be appealing to the wrong crowd (as I expect this stuff is all
> part of the Servlet spec), but this somehow seems to be less modular
> than I would like. It seems that the spirit or .war files is to be an
> extension of the .jar file concept, generalized to entire j2ee
> applications. When I obtain a .jar file for classes I would like to
> use -- all I need to do is place that .jar file in my CLASSPATH and I
> can use the classes. The analogy does not seem to fully carry over
> into .war files. Would it not be better if I was able to package my
> entrire application and supporting resources (html, xml, tld,
> etc.. files) and have the servlet or j2ee system know how to access
> all of those resources in a generic way, similar to the approach with
> .jar files and classes? It seems that the current approach only goes
> half way -- I can introduce a .war file and have the servlet container
> interpret its structure in some ways (making a context, recognizing
> the docroot, etc), but not in other ways (allowing my jsp files to
> import or declare taglibs contained in the .war file, or recognize classes)
> 

Well, you've certainly got most of the "self contained" stuff you are
after:
* Want to use a JAR file in your app?  Stick it into /WEB-INF/lib
  and it is automatically available to you.
* Want to access a static resource in your app?  Use
  ServletContext.getResource() and you don't have to care how the
  servlet container deals with it.
* Want to change the context path of your app?  The details of how
  to do this vary by servlet container, but it's trivially easy
  (especially with Struts) to make your application independent
  of what the actual context path is.
* Want to us a tag library?  Somehow, you've got to create a mapping
  from the URI used in your pages to the corresponding TLDs.  There
  are a variety of ways to do this, but I've found that explicitly
  referencing TLDs in the WEB-INF directory is the least confusing.

> Is there some design reason for this that I do not understand? It
> seems things could be architected such that the steps you outline
> below are not needed.
> 

For the separate TLD files themselves, there's a spec-related issue that
caused this approach.

The JSP 1.1 spec defines the concept of a tag library that is encapsulated
in a single JAR file (including the TLD, which you placed at the
META-INF/tablib.tld entry.  Thus, you could just drop a tab library into
your WEB-INF/lib directory, create a URI for it in web.xml, and go.

Now, originally, Struts only had one tag library, so this strategy was
quite useful -- stick the "struts.tld" file into struts.jar, and
everything was fine.  However, Struts now has four tag libraries (and the
number is likely to grow in the future).  But you cannot have more than
one encapsulated TLD in a single JAR file in JSP 1.1 -- and separating
struts.jar into five JAR files doesn't really help anything.

In JSP 1.2, this changes -- you'll be able to to encapsulate all of the
Struts tag libraries in struts.jar and dispense with the separate TLD
files.  But, until JSP 1.2 containers are widely deployed, we're stuck
with the 1.1 restrictions.

But the bottom line is that the architecture of web applications is
defined by the servlet spec.  Therefore, Struts has to live within those
rules, just like any other web application or framework based on servlets
will have to.

> -will
> 
> 

Craig



Re: installing struts taglibs

Posted by William Shulman <wi...@metaconsortium.com>.
thanks Craig-

I may be appealing to the wrong crowd (as I expect this stuff is all
part of the Servlet spec), but this somehow seems to be less modular
than I would like. It seems that the spirit or .war files is to be an
extension of the .jar file concept, generalized to entire j2ee
applications. When I obtain a .jar file for classes I would like to
use -- all I need to do is place that .jar file in my CLASSPATH and I
can use the classes. The analogy does not seem to fully carry over
into .war files. Would it not be better if I was able to package my
entrire application and supporting resources (html, xml, tld,
etc.. files) and have the servlet or j2ee system know how to access
all of those resources in a generic way, similar to the approach with
.jar files and classes? It seems that the current approach only goes
half way -- I can introduce a .war file and have the servlet container
interpret its structure in some ways (making a context, recognizing
the docroot, etc), but not in other ways (allowing my jsp files to
import or declare taglibs contained in the .war file, or recognize classes)

Is there some design reason for this that I do not understand? It
seems things could be architected such that the steps you outline
below are not needed.

-will


Craig R. McClanahan writes:
 > Copying the WAR files is how you would install the example applications
 > that come with Struts.  For your own apps, you basically need to:
 > - Add "struts.jar" to the WEB-INF/lib directory of your webapp
 > - Copy the Struts TLD files into the WEB-INF directory of your
 >   webapp (although some prefer WEB-INF/tlds instead)
 > - Make the URIs you use in web.xml and/or your pages point at wherever
 >   you actually installed these TLDs.
 > 
 > Craig
 > 
 > 

Re: installing struts taglibs

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 20 Jun 2001, William Shulman wrote:

> 
> Hello -
> 
> I have been using the struts tablibs for a few weeks now and
> integrated them with my application by adding taglib declarations in
> my web.xml file to point to the struts tld files. However, I was
> reading the installation notes again and noticed that another way to
> install struts is to simply copy all of the struts .war files into my
> webapps directory. However, it seems that I still have to modify my
> web.xml file to include the struts taglibs. Is this the case or am I
> doing someting wrong. I was hoping I could just copy the .war files
> and be done.
> 
> -will
> 
Copying the WAR files is how you would install the example applications
that come with Struts.  For your own apps, you basically need to:
- Add "struts.jar" to the WEB-INF/lib directory of your webapp
- Copy the Struts TLD files into the WEB-INF directory of your
  webapp (although some prefer WEB-INF/tlds instead)
- Make the URIs you use in web.xml and/or your pages point at wherever
  you actually installed these TLDs.

Craig