You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luis Andrei Cobo <va...@megapathdsl.net> on 2000/07/23 22:59:42 UTC

Cache issue...help?

I dont knwo if you any of you have had this experience:

I currently created a form loop wich asks user for variety of information.
It uses a shared handler page which parses the input and stores it in a
table. It goes throuhg the process about 9 times. interestingly whe I
checked the table it was inserting the data 9 times from the first page, 8
times from the secind page 7 times ofr page 3 etc etc .. It seems as though
the form handler is caching the insert statements each time its called and
just appeneds the insert statement to the end of the set it had previously.
Thus, entering the same data again and again.

Is there a way to flush and re-instatiate the page from scratch each time it
gets called? otherwise I'll have not only a cache-control issue but a
threading issue later on when many many people use this page.

sample code for the insert statements loop:

for(i=0;i<params.size();i++) {
	java.sql.Statement stmt3;
	java.sql.ResultSet rs3;
	StringBuffer buf = new StringBuffer();
	buf.append("Insert into user_scores(column1,column2, column3, column4)
values('");
	buf.append((String)session.getValue("column1") + "','" +
params.elementAt(i) + "','" + values.elementAt(i) + "','" +
(String)session.getValue("UserID") + "')");
	stmt3 = dbconn.createStatement();
	//out.println(buf.toString() + "<br>");
	rs3 = stmt3.executeQuery(buf.toString());
	buf = null;
	stmt3 = null;
	rs3 = null;
}

Luis



Re: Cache issue...help?

Posted by "Edward W. Rouse" <er...@vei.net>.
try
stmt3.close();
rs3.close();

instead of setting them to null.
Ed.

Luis Andrei Cobo wrote:

> I dont knwo if you any of you have had this experience:
>
> I currently created a form loop wich asks user for variety of information.
> It uses a shared handler page which parses the input and stores it in a
> table. It goes throuhg the process about 9 times. interestingly whe I
> checked the table it was inserting the data 9 times from the first page, 8
> times from the secind page 7 times ofr page 3 etc etc .. It seems as though
> the form handler is caching the insert statements each time its called and
> just appeneds the insert statement to the end of the set it had previously.
> Thus, entering the same data again and again.
>
> Is there a way to flush and re-instatiate the page from scratch each time it
> gets called? otherwise I'll have not only a cache-control issue but a
> threading issue later on when many many people use this page.
>
> sample code for the insert statements loop:
>
> for(i=0;i<params.size();i++) {
>         java.sql.Statement stmt3;
>         java.sql.ResultSet rs3;
>         StringBuffer buf = new StringBuffer();
>         buf.append("Insert into user_scores(column1,column2, column3, column4)
> values('");
>         buf.append((String)session.getValue("column1") + "','" +
> params.elementAt(i) + "','" + values.elementAt(i) + "','" +
> (String)session.getValue("UserID") + "')");
>         stmt3 = dbconn.createStatement();
>         //out.println(buf.toString() + "<br>");
>         rs3 = stmt3.executeQuery(buf.toString());
>         buf = null;
>         stmt3 = null;
>         rs3 = null;
> }
>
> Luis