You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by KY K Lui <ky...@mailcity.com> on 2000/05/27 18:21:24 UTC

use servlet context in a bean

i want to use bean in my jsp page.

I have a application scope bean which has id="beanid"

How can other bean access this application bean?
can i use "getServletContext().getAttribute("beanid");"?
however if i use this, my bean needs to extends HttpServlet.

i like a servlet rather than a bean.......
am i right?

thanks


Get your FREE Email at http://mailcity.lycos.com
Get your PERSONALIZED START PAGE at http://my.lycos.com

Re: use servlet context in a bean

Posted by Derek DeMoro <dd...@home.com>.
No.  You should create a bean called "WebBean" or something to that nature.
WebBean should have a method called initialize which initializes all the jsp
objects
in your bean so you can use them.

Ex.
<jsp:useBean class="foo" id="f" scope="application">
</jsp:useBean>

<% f.initialize(application, session, request, response ,out); %>


----- Original Message -----
From: "KY K Lui" <ky...@mailcity.com>
To: <to...@jakarta.apache.org>
Sent: Saturday, May 27, 2000 9:21 AM
Subject: use servlet context in a bean


> i want to use bean in my jsp page.
>
> I have a application scope bean which has id="beanid"
>
> How can other bean access this application bean?
> can i use "getServletContext().getAttribute("beanid");"?
> however if i use this, my bean needs to extends HttpServlet.
>
> i like a servlet rather than a bean.......
> am i right?
>
> thanks
>
>
> Get your FREE Email at http://mailcity.lycos.com
> Get your PERSONALIZED START PAGE at http://my.lycos.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>