tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Delagrange, Morgan" <mdela...@us.britannica.com>
Subject RE: beans vs. tags
Date Tue, 23 Jan 2001 21:53:26 GMT


> -----Original Message-----
> From: Robert Karen [mailto:robert_karen@yahoo.com]
> Sent: Tuesday, January 23, 2001 2:37 PM
> To: taglibs-user@jakarta.apache.org
> Subject: beans vs. tags
> 
> 
> Newbie design question:
> 
> In light of 'JSP is a view technology', how would
> propose designing the following. Suppose you desire
> a tag/component web designers can include to track
> pages read by users and store it in a database.
> Would you discourage tags and use beans exclusively,
> or use a tag ie <tracking:InsertTrack page=page1.jsp>.

If that's literally all you want to do, a Bean is probably a better bet.
They're (very slightly) faster and easier to write/maintain.

However, if you have some need for much more configuration, it could be a
good candidate for a tag library.  Here's a naive example:

  <%@ taglib uri="tracking" prefix="tracking" %>
  <%@ taglib uri="request" prefix="req" %>
  <%@ taglib uri="session" prefix="session" %>

  <req:request id="rq"/>
  <sesssion:session id="session"/>
  
  <tracking:insertTrack>
    <tracking:requestURI><jsp:getProperty 
       name="rq" property="requestURI"/></tracking:requestURI>
    <tracking:sessionId><jsp:getProperty 
       name="session" property="id"/></tracking:sessionId>
  </tracking:insertTrack>

Put this guy in its own JSP and include it, and you've got relatively
unobtrusive user tracking.  The nice thing about JSP custom tags are their
potential interoperability.

> And if you had a number of different tags that used
> the
> same database, where would you place a connection
> whose
> instance could be shared?
> 
> Robert Karen

That's definitely not something you need to manage inside of your JSP.  I
find virtual pooling drivers to be the easiest solution, especially since
they don't affect the usage of custom SQL tag.

> --- "Delagrange, Morgan" <mdelagra@us.britannica.com>
> wrote:
> > Hi Robert, Hi Jeff,
> > 
> > 
> > Jeff, generally I agree that JSP is a view
> > technology, but I don't see a
> > good reason to restrict it to that.  In this
> > particular example, if what you
> > desire in your view closely matched the database
> > contents, I don't see a
> > compelling reason to push the model out to a Bean. 
> > Many other
> > template-based technologies use direct database
> > connectivity to good effect.
> > 
> > - Morgan
> > 
> > 
> > > -----Original Message-----
> > > From: Ward, Jeff [mailto:jward@BenefitPoint.com]
> > > Sent: Monday, January 22, 2001 3:23 PM
> > > To: 'taglibs-user@jakarta.apache.org'
> > > Subject: RE: sql tag lib.
> > > 
> > > 
> > >   They are all inside of the page context that is
> > passed into 
> > > the tag on
> > > init. Depending on what scope you declared the
> > bean to be it 
> > > will appear in
> > > either the page, request, session or application
> > scopes. If you use
> > > PageContext.findAttribute() it will search all of
> > them for you.
> > > 
> > >   Now, on another note.....
> > > <soapbox>
> > >   I have been noticing a lot of SQL libs and the
> > like popping 
> > > up and I was
> > > wondering what other peoples opinions are of these
> > functional type
> > > libraries. To me, taglibs are a pure view
> > technology. Things 
> > > like sql tag
> > > libs miss the point entirely and lead to the
> > single layer web 
> > > app with all
> > > the maintenance nightmares that come with it.
> > >   I'm just trying to get a feel for how people
> > envision tag 
> > > libs use and the
> > > future of the things. Any thoughts?
> > > </soapbox>
> > >  
> > >   -Jeff Ward
> > > 
> > >  -----Original Message-----
> > > From: 	Robert Karen
> > [mailto:robert_karen@yahoo.com] 
> > > Sent:	Monday, January 22, 2001 12:17 PM
> > > To:	taglibs-user@jakarta.apache.org
> > > Subject:	sql tag lib.
> > > 
> > > I'm toying with writing a short tag lib
> > > that would use a database connection.
> > > How could I scope the connection at the
> > application
> > > or session and pass/access the connection instance
> > in
> > > the taglib instance? My thoughts were to have a
> > > generic connection bean, but I don't know how to
> > > get to it to the taglib. 
> > > 
> > > Thanks for any guidance.
> > > 
> > > Robert Karen
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Auctions - Buy the things you want at great
> > prices. 
> > > http://auctions.yahoo.com/
> > > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices. 
> http://auctions.yahoo.com/
> 

Mime
View raw message