wood burning stoves 2.0*
The moose likes JSP and the fly likes Tag variable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Tag variable problem" Watch "Tag variable problem" New topic
Author

Tag variable problem

Sam Wang
Ranch Hand

Joined: Jul 17, 2001
Posts: 95
I write some custom tags about sql.As follow:
<mytag:connection driver="driver-class" url="db-url" />
<mytag:query >some sql</mytag:query>
...
The connection tag will set a java.sql.Connection as a attribute of pageContext.It is also defined in connectionExtraInfo and tld.
My problem is i can't get connection after the connection tag end.
Please.


SCJP(2001)
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Did you code for to open the connection after the end tag ? ( in doEndTag() may be ..)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60783
    
  65

You can store the connection as a request or page attribute and retrieve it from the page after the tag is closed. If you also use a TEI class for your tag, you can automatically create a page variable for the object.
I'd caution to be sure you free the connection (or return it to the pool or whatever) on the page when you are done with it. Since lots of things can interrupt page processing, a try/finally block might be good insurance.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Tag variable problem
 
Similar Threads
Jboss- Mssql configuration porblem
JBOSS startup error
running out of ManagedConnections available
ms sql server2000 and jboss
Could not create connection in Jboss 4.2.2GA