tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Holmes III, William S" <william.s.holmes....@lmco.com>
Subject RE: useBean tag
Date Mon, 07 Aug 2000 12:35:39 GMT
Sorry, C++ memory leak...  I meant "import javax.servlet.*"
Craig McClanahan was part of a thread on jsp-interest for model 2 JSP
architectures a couple months ago. In the thread he seemed to suggest that
beans shouldn't be aware that they are being used in a servlet environment.
I think it takes away from how portable the bean is and could mean latter
design changes/trade-offs when dealing with EJBs or EAI.

BTW. Thanks for the reply on the JSP compilation error.

> -----Original Message-----
> From:	Steven.Shaw@savillemail.com [SMTP:Steven.Shaw@savillemail.com]
> Sent:	Sunday, August 06, 2000 10:15 PM
> To:	tomcat-user@jakarta.apache.org
> Subject:	RE: useBean tag
> 
> 
> 
> What do you mean by "#include javax.servlet.*"
> 
> 
> 
> 
> 
> william.s.holmes.iii@lmco.com on 04/08/2000 23:38:29
> 
> Please respond to tomcat-user@jakarta.apache.org
>                                                               
>                                                               
>                                                               
>  To:      tomcat-user@jakarta.apache.org                      
>                                                               
>  cc:      (bcc: Steven Shaw/Net)                              
>                                                               
>                                                               
>                                                               
>  Subject: RE: useBean tag                                     
>                                                               
> 
> 
> 
> 
> 
> 
> 
> I thought making beans include servlet information (#include
> javax.servlet.*) was frowned upon.
> 
> > -----Original Message-----
> > From:   Steven.Shaw@savillemail.com [SMTP:Steven.Shaw@savillemail.com]
> > Sent:   Thursday, August 03, 2000 10:28 PM
> > To:     tomcat-user@jakarta.apache.org
> > Subject:     useBean tag
> >
> >
> >
> > The useBean tag seems to be less than useful when accessing session
> > attributes.
> > Say I have a bean called "com.foo.beans.CustomerBean" i.e. that is it's
> > attribute-name set from a servlet. I then try to access the bean from a
> > JSP
> > using the useBean tag.
> >
> >      <jsp:useBean id="customerBean" .... />
> >
> > How can I do this? It seems I need something like:
> >
> >      <jsp:useBean id="customerBean" scope="session"
> > name="com.foo.beans.CustomerBean" />
> >
> > Currently I am working around this with some code like this:
> >
> >      <% customerBean = CustomerBean.get(request); %>
> >
> > The CustomerBean.get is a static method which lazily instantiates the
> > bean:
> >
> > public class CustomerBean {
> >     private static BEAN_NAME = "com.foo.beans.CustomerBean";
> >
> >     public static CustomerBean get(HttpRequest request) {
> >         HttpSession session = request.getSession();
> >         CustomerBean bean = (CustomerBean)
> > session.getAttribute(BEAN_NAME);;
> >         if (bean == null) {
> >             synchronized (session) {
> >                 bean = (CustomerBean) session.getAttribute(BEAN_NAME);;
> >                 if (bean == null) {
> >                     bean = new CustomerBean();
> >                     session.setAttribute(BEAN_NAME, bean);
> >                 }
> >             }
> >         }
> >         return careSession;
> >     }
> > .....
> >
> > Any comments. Am I missing something?
> >
> > cheers,
> >
> > Steve.
> >
> 
> 

Mime
View raw message