• Post Reply Bookmark Topic Watch Topic
  • New Topic

custom tags (taglib)

 
Ron Boles
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings from Australia.
I am designing a JSP app using custom-tags to control content. (MVC framework would be overkill)
I prefer to have no java code in my JSP pages,
just custom-tags and html.
One of my tags will validate usr/pwd against a mysql database.
I would like to establish a connection pool,
just as I would in init(), if I were using a servlet.
However, it appears that custom-tag classes (extends BodyTagSupport) are instantiated each time the jsp page is loaded.
Does anybody have any suggestion on how I can use connection pooling with my custom tag classes ??
(and keep java content in my JSP page to a minimum)
Thanks in advance
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place the reference to your DB Pool Class in the ServletContext. You can use a tag to ensure it is setup or have a standard call in each tag where you need a connection. Use code similar to
 
Ron Boles
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Carl,it worked a treat.
Just one question re JSP from a newbie...
Is it bad form to put all java code inside
custom tags and use the JSP as display-only.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Form is established by the Company and developer. Probably, the best form is to have your JSP strictly tags. It's easier at that point to ship the HTML development to someone with this expertise.
 
Joe Pardi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron,
If your preference is tags, take a good look at the jakarta tag library. It has some useful tags to do some pretty mundane things.
Also, take a peek at a new library called dotJ - http://www.dotjonline.com
The grid tag and the HTML form tags are pretty cool.
Good luck ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!