aspose file tools*
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
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: 61229
    
  66

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag variable problem