tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Baer <jonb...@digitalanywhere.com>
Subject Re: Creating Your Own Implicit Objects
Date Sat, 17 Jun 2000 01:16:32 GMT
Hmmm I see what you are saying and I have to say I found the ActionServlet of Structs
very useful.  But on my original question what I meant is by allowing something like
object declaration in a taglib and then being accessible outside the tag.  The approach
I want to take is similar to what you have where the taglib loads all the mappings of a
prop file and then uses it throughout the page as such example:

<% @ taglib uri="uri" prefix="load" %>
<load:map file="file.map"/>

<!-- now the file is loaded and you can use an object from the taglib -->

Here is the value of <% mapValue.getName(0) %> : <% mapValue.getValue(0) %>

So that mapValue is available throughout the JSP page without having to declare a tag
for it.  Is this possible?

- Jon

"Craig R. McClanahan" wrote:

> Jon Baer wrote:
>
> > Hi,
> >
> > This is more of a programming question using Tomcat, I am interested in how to
> > accomplish via JSP/Servlet 2.2 on how to create your own implicit objects in a
> > page.  Does anyone have any reference for this or a piece of code that shows it
> > being done?  Im told you can do it though a taglib but I havent seen it in an
> > examples.
> >
>
> You can indeed create new implicit objects in a custom tag (portable across any
> servlet 2.2/JSP 1.1 container, not just Tomcat).  For just one example, check out
> the <struts:enumerate> tag (Java class is org.apache.struts.taglib.EnumerateTag)
in
> the Struts framework project at <http://jakarta.apache.org/struts>.  It creates
an
> implicit object for the current element of a collection that is visible to other
> tags (and scriptlets) on the current page, as well as allowing you to loop through
> all the elements of an Enumeration or an array.
>
> If you are using an architecture that forwards to a JSP page (using
> RequestDispatcher.forward), you should also know that there is a direct
> correspondence between the attributes models for servlets and JSP pages:
>
> * Request attributes (servlet) == request scope beans (JSP)
> * Session attributes (servlet) == session scope beans (JSP)
> * ServletContext attributes (servlet) == application scope beans (JSP)
>
> This correspondence makes it very easy to share information between the various
> servlets and JSP pages in your web application.
>
> >
> > Thanks.
> >
> > - Jon
> >
>
> Craig McClanahan
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message