tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Creating Your Own Implicit Objects
Date Sat, 17 Jun 2000 00:11:38 GMT
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 <>.  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

View raw message