tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Delisle <pierre.deli...@sun.com>
Subject Re: newbie: why isn't jsp variable initialized?
Date Fri, 09 Feb 2001 01:17:08 GMT
Replace 
  <%! int myline = 1; %>  [declaration]
with 
  <% int myline = 1; %>   [scriptlet]

    -- Pierre

Robert Karen wrote:
> 
> I've been experimenting with <sql> taglib and a
> taglib I created to parse results. I found that
> when I call the jsp file again (from an html form)
> that a new database connection is opened (I want
> this), but the line numbers (scriptlet variable
> myline)
> start counting from where they remained
> the last time I ran saw the page. Why isn't it being
> initialized again in each page? I'm using Tomcat 3.2.
> Thanks for any help.
> 
> Robert Karen
> Here is the file:
> 
> <%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %>
> <%@ taglib uri="/WEB-INF/bldinserttag.tld"
> prefix="trackerSansDb"%>
> <html>
> <head>
> <title>Examples of JSPSPEC SQL Tag Library Tag
> Usage</title>
> </head>
> <body bgcolor="white">
> 
> <sql:connection id="conn1" >
>   <sql:dburl><%= request.getParameter("dburl")
> %></sql:dburl>
>   <sql:driver><%= request.getParameter("driver")
> %></sql:driver>
>   <sql:userid><%= request.getParameter("userid")
> %></sql:userid>
>   <sql:password><%= request.getParameter("password")
> %></sql:password>
> </sql:connection>
> 
> <trackerSansDb:showAllResSet dataSet="mydata">
>   <sql:query id="getBoxen" connection="conn1"
> visibility="table">
>     select userid || '|' ||
>       pageid || '|' ||
>       to_char (timeviewed, 'MON DD, YYYY HH:MI:SS') ||
> '|' ||
>       client_address || '|' ||
>       sessionid
>       from user_pages_viewed
>       order by userid , timeviewed
>   </sql:query>
> </trackerSansDb:showAllResSet>
> <%--
>   -- close the connection or it doesn't get closed
> until oracle times it out.
>   --%>
> <%@ page import="java.io.IOException, java.sql.*" %>
> <% try {conn1.close();%>
>     <br><h2>CLOSING CONNECTION FROM
> SCRIPTLET.<br></h2>
> <%  } catch (SQLException e) {%>
>     <br><h2>UNABLE TO CLOSE CONNECTION.<br></h2>
>   <% }  %>
> <table border="1" align="left">
> <%-- showAllLoop gets data from mydata (ArrayList page
> attribute) --%>
> <%! int myline = 1; %>
> <trackerSansDb:showAllLoop dataSet="mydata">
>   <tr>
>      <%-- showCols gets 1 row from
> findAncestorWithClass().getCurrentRow --%>
>      <td align="right">
>        <%=myline%>
>        <% myline++; %>
> <% try {conn1.close();%>
>     <br><h2>CLOSING CONNECTION FROM
> SCRIPTLET.<br></h2>
> <%  } catch (SQLException e) {%>
>     <br><h2>UNABLE TO CLOSE CONNECTION.<br></h2>
>   <% }  %>
> <table border="1" align="left">
> <%-- showAllLoop gets data from mydata (ArrayList page
> attribute) --%>
> <%! int myline = 1; %>
> <trackerSansDb:showAllLoop dataSet="mydata">
>   <tr>
>      <%-- showCols gets 1 row from
> findAncestorWithClass().getCurrentRow --%>
>      <td align="right">
>        <%=myline%>
>        <% myline++; %>
>      </td>
>      <trackerSansDb:showCols id="row" >
>        <td><jsp:getProperty name="row"
> property="currentCol"/></td>
>      </trackerSansDb:showCols>
>   </tr>
> </trackerSansDb:showAllLoop>
> </table>
> </body>
> </html>
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35
> a year!  http://personal.mail.yahoo.com/

Mime
View raw message