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.
posted 15 years ago
Did you code for to open the connection after the end tag ? ( in doEndTag() may be ..)
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