Richard Yumul wrote:

> I've found when I want to utilize beans in a jsp page, I'd like the beans to be
> aware of the environment that they're being used in.  Namely, I'd like them to
> have access to the HttpServletRequest (and possibly the HttpServletResponse)
> methods.  I remember in the 0.91 or 0.92 spec that if a bean in a JSP page
> extended/implemented Servlet (or was it HttpServlet?), the bean's
> service(HttpServletRequest, HttpServletResponse) method would be called.
>
> Other than breaking into a scriptlet & doing something like:
>
> <%
> bean.setRequest(request);
> bean.setResponse(response);
> %>
>
> is there some automated mechanism in which the bean can discover it's
> environment?  If not, can somebody explain to me why this mechanism was canned?
>
> Thanks,
> Rich
>

In the JSP 1.1 spec, there is the ability to create custom tag extensions that are
portable across servers.  The tag extension mechanism is actually powerful enough
to implement all the standard <jsp:xxxxx> elements (although a given
implementation may hard code its handling of these for efficiency).  One of the
example custom tags is a customized <jsp:useBean> that does exactly the kind of
thing you are talking about automatically.

IMHO, the hard-wired call to processRequest() was bagged in 1.0 for the same
reason that <loop> and <display> were bagged -- they were special cases for
specific purposes, where what JSP really needed was a general purpose mechanism to
define tags that can do these things, and a whole bunch more.  That is what the
tag extension mechanism lets you do.  I expect we will see a *bunch* of tag
extension libraries created (both commercial and freeware), just as happened when
the JavaBeans spec was formalized and created a market for beans.

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to