From taglibs-user-return-1431-apmail-jakarta-taglibs-user-archive=jakarta.apache.org@jakarta.apache.org Fri Oct 26 19:50:56 2001 Return-Path: Delivered-To: apmail-jakarta-taglibs-user-archive@jakarta.apache.org Received: (qmail 84197 invoked by uid 500); 26 Oct 2001 19:50:55 -0000 Mailing-List: contact taglibs-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: taglibs-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list taglibs-user@jakarta.apache.org Received: (qmail 84160 invoked from network); 26 Oct 2001 19:50:54 -0000 Message-ID: <001a01c146a6$0b8007e0$ccef99c2@vega> From: "alex" To: References: <8CE5617ED444D411BDF800508BDF0BEE06E1EE3E@usahm015.exmi01.exch.eds.com> Subject: Re: DBTags Tag library Date: Wed, 26 Sep 2001 19:12:30 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0017_01C146BF.30546660" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0017_01C146BF.30546660 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thank you Steve for the patch. It works for me too. I hope someone will = hear us and include it in the next release. Best regards, Alex ----- Original Message -----=20 From: Mader, Steve=20 To: 'taglibs-user@jakarta.apache.org'=20 Sent: Wednesday, October 24, 2001 6:39 PM Subject: RE: DBTags Tag library=20 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() !=3D null && getPreviousOut() !=3D 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() !=3D null && getPreviousOut() !=3D null && _shouldLoop =3D=3D 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 -----Original Message----- From: alex [mailto:alex@soft-expert.com] Sent: Sunday, September 23, 2001 7:55 AM To: taglibs-user@jakarta.apache.org Subject: DBTags Tag library=20 Hi, There is a small problem I saw when using DBTags library with JRun = engine and IIS 5.0 and ODBC database access. What is happening: when I use a SELECT which does not return = anything, so it's unsuccesful, the generated webpage contains also the = SELECT statement into it !=20 Here is a piece of the code: =20 SELECT Info_id, Details FROM Informative WHERE Type =3D 1

  • <%String id =3D rset1.getString(1);%>
  • When there are no results, I get a string: SELECT Info_id, Details FROM Informative WHERE Type =3D 1 Not very pretty, isn't it ?=20 I believe, but I may speak foolish things, that the context's output = buffer is flushed only inside a block where some results are obtained so = the case when no results are returned isn't considered. A last thing: I used wasEmpty AND/OR wasNotEmpty with no results in = solving the problem. I also observer that is not happening 100% ! = Sometimes, somehow I managed to avoid this situation. (??) I do not expect help on this matter ; maybe only a confirmation that = this happens elswere. For Marius Scurtescu : Da-i inainte ca faci o treaba buna ! Ma bucur sa vad nume d'ale = noastre pe aici. Regards, Alex ------=_NextPart_000_0017_01C146BF.30546660 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
    Thank you Steve for the patch. It works = for me too.=20 I hope someone will hear us and include it in the next = release.
    Best regards,
    Alex
     
    ----- Original Message -----
    From:=20 Mader,=20 Steve
    To: 'taglibs-user@jakarta.a= pache.org'=20
    Sent: Wednesday, October 24, = 2001 6:39=20 PM
    Subject: RE: DBTags Tag library =

    I=20 was having this same issue.  It seemed to only happen if the = query first=20 returned rows and then I made another call to the same query=20 (with different input) and it returned zero rows.  = Looking at=20 the source for ResultSetTag.java, it seemed to have something to do = with the=20 processing of the end tag.  doEndTag() has the following=20 code:
     
      public int doEndTag() throws=20 JspTagException{
       =20 pageContext.removeAttribute(getId());
        try=20 {
          if (getBodyContent() !=3D null = &&=20 getPreviousOut() !=3D null) = {
           =20 = getPreviousOut().write(getBodyContent().getString());
      &nbs= p;  =20 }
        } catch (IOException e)=20 {
          throw new=20 JspTagException(e.toString());
        } finally=20 {
          try=20 {
           =20 _rset.close();
         =20 }
          catch (SQLException e)=20 {
            // it's not fatal if = the=20 result set cannot be = closed
           =20 e.printStackTrace();
          = }
       =20 }
     
        // we have to call this guy manually=20 now
        // with the spec = clarification
       =20 release();
     
        return EVAL_PAGE;
      = }
     
     
    It=20 seems the line that writes the body content is writing the content of = the SQL=20 query when no rows are returned.  (getPreviousOut().write(getBodyContent().getString());) I=20 modified the if-block as follows and I no longer have the=20 problem:
     
    if ( getBodyContent() !=3D null = &&
        =20 getPreviousOut() !=3D null &&
         = _shouldLoop =3D=3D=20 true &&
         _rowCount >=20 0
       )
    {
       =20 = getPreviousOut().write(getBodyContent().getString());
    }
     
    This may not be a perfect fix, but it's working for me.  = I'm only=20 using the ResultSet tag for iterating over the result set (the loop = attribute=20 is true).
     
    Steve Mader
    -----Original Message-----
    From: alex=20 [mailto:alex@soft-expert.com]
    Sent: Sunday, September 23, = 2001=20 7:55 AM
    To: = taglibs-user@jakarta.apache.org
    Subject:=20 DBTags Tag library

    Hi,
    There is a small problem I saw when = using=20 DBTags library with JRun engine and IIS 5.0 and ODBC database=20 access.
    What is happening: when I use a = SELECT which=20 does not return anything, so it's unsuccesful, the generated webpage = contains also the SELECT statement into it !
    Here is a piece of the = code:
     
    <sql:statement id=3D"stmt1" = conn=3D"conn1">=20
      <sql:query>
        SELECT Info_id, = Details=20 FROM Informative
     WHERE Type =3D 1
     =20 </sql:query>
      <sql:resultSet id=3D"rset1"=20 >
          <LI>
      =20  <sql:getColumn=20 position=3D"2"/><BR>
      <%String id = =3D =20 rset1.getString(1);%>
       </LI>
     =20 </sql:resultSet>
    </sql:statement>
    When there are no results, I get a=20 string:
        SELECT Info_id, = Details FROM=20 Informative
     WHERE Type =3D 1
    Not very pretty, isn't it ? =
    I believe, but I may speak = foolish=20 things, that the context's output buffer is flushed only inside a = block=20 where some results are obtained so the case when no results are = returned=20 isn't considered.
     
    A last thing: I used wasEmpty = AND/OR=20 wasNotEmpty with no results in solving the problem. I also observer = that is=20 not happening 100% ! Sometimes, somehow I managed to avoid this = situation.=20 (??)
     
    I do not expect help on this = matter ;=20 maybe only a confirmation that this happens = elswere.
     
    For Marius=20 Scurtescu :
    Da-i inainte ca faci o treaba buna ! Ma bucur sa vad nume = d'ale=20 noastre pe aici.
     
    Regards,
    Alex
     
     
     
    ------=_NextPart_000_0017_01C146BF.30546660--