I was
having this same issue. It seemed to only happen if the query first
returned rows and then I made another call to the same query
(with different input) and it returned zero rows. Looking at the
source for ResultSetTag.java, it seemed to have something to do with the
processing of the end tag. doEndTag() has the following
code:
public int doEndTag() throws
JspTagException{
pageContext.removeAttribute(getId()); try { if (getBodyContent() != null && getPreviousOut() != null) { getPreviousOut().write(getBodyContent().getString()); } } catch (IOException e) { throw new JspTagException(e.toString()); } finally { try { _rset.close(); } catch (SQLException e) { // it's not fatal if the result set cannot be closed e.printStackTrace(); } } // we have to call this guy manually
now
// with the spec clarification release(); return EVAL_PAGE;
} It
seems the line that writes the body content is writing the content of the SQL
query when no rows are returned. (getPreviousOut().write(getBodyContent().getString());) I
modified the if-block as follows and I no longer have the
problem:
if ( getBodyContent() != null &&
getPreviousOut() != null && _shouldLoop == true && _rowCount > 0 ) {
getPreviousOut().write(getBodyContent().getString());
} This may not be a perfect fix, but it's working for me. I'm only
using the ResultSet tag for iterating over the result set (the loop attribute is
true).
Steve Mader
|
- DBTags Tag library alex
- RE: DBTags Tag library Mader, Steve
- Re: DBTags Tag library Mader, Steve
- Re: DBTags Tag library alex
- NoSuchMethodException while using Taglib... Gopalakrishnan Ramanujam