tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Alfors <>
Subject Re: exposing script variables
Date Tue, 24 Apr 2001 21:05:52 GMT
Oops.. I miss-typed.
Here is what I am currently doing:

<itl:define id="organizationsBean" scope="session"/>
<jsp:useBean id="organizationsBean"
<% String organizationId = (String)
organizationsBean.getColumn("ORGANIZATIONID"); %>

The define tag retrieves the specified object from my own session management
utility.  The session scope in the define tag is different
from the httpsession.  This is why I cannot use the jsp:useBean to retrieve the
object directly.
The define tag then places the object in the request which allows the jsp:useBean
tag to retrieve it and make it available to the page.
There are multiple places on the page that I want to access this bean.
Therefore, I would need to replace the jsp:useBean line with something like:

<% OrganizationsBean organizationsBean = (OrganizationsBean)
pageContext.getAttribute("organizationsBean"); %>

I would like to minimize the amount of JSP script there is on the page.
Using the jsp:useBean tag, I can omit this line.  Ideally, I want to omit the
jsp:useBean line and just have:

<itl:define id="organizationsBean" scope="session"/>
<% String organizationId = (String)
organizationsBean.getColumn("ORGANIZATIONID"); %>

It is obviously possible to do.  I just can't seem to figure out what it is.


Morgan Delagrange wrote:

> Actually, you did put your attribute in the session context.  The
> findAttribute(String) method of the page context searches all the context
> (first page, then request, then session, then application) for your
> attribute.  The alternative is the getAttribute(String) method of each
> scope, which only searches that scope.  In your case:
> String organizationId =
> session.getAttribute("organizationsBean").getColumn("ORGANIZATIONID");
> Using getAttribute is probably more efficient, but if you're designing
> tags, findAttribute is more convenient.  I think that if you don't specify
> a scope in getProperty, it uses the same logic as findAttribute.
> - Morgan
> On Tue, 24 Apr 2001, Dave Newton wrote:
> > Hola,
> >
> > >> [...] This new tag needs to be able to make an object available as a
> > scripting variable. [...]
> > > String organizationId =
> > pageContext.findAttribute("organizationsBean").getColumn("ORGANIZATIONID");
> >
> > As a relative servlet/JSP newbie, I'm wondering why it would be better
> > to put things in the pageContext rather than directly in the request
> > or session or whatever.
> >
> > Thanks,
> > Dave
> >
> >

View raw message