There are a few things to do with JSP's
and copies of objects in JSP's,
when it comes to variables of
session and page
scopes.
A text/ebook like "special edition using Java 2 enterprise edition
clarifies this, but it all goes to the fact that a jsp ends
by being compiled into a servlet, which is injected
and then executed from there.
This means that every client run of the jsp
is running from THE SAME class of your programmed jsp,
though from different execution context instances.
You need to be careful that each page variable object
doesn't conflict with other objects by use of page objects.
You will want each copy of your resultset Object,
in each jsp page contextn, to be a unique object context, and have all of
them,
ins your jsp, be dirty references back to your original copy.
It should, optmistically, be unbound from your resultSet Object produced by
bean/corba/rmi/ejb/whatever object source.
In your example, in a situation where each jsp page
may alter it's unique resultset object later on,
-you may use a to managelibrary class/bean/enterprise javaban
to have setResultSet/getResultSet methods. These methods may have somethig
like a linkedlist that holds resultsetl objects (or a complexresultset
object of yous,
with field int field = 1; with this reflected in get/set function
signatures.
from hear, each page may the obtain it's own particular
pageContext copy of your resultselt object.
Or, you may use a linked list approach, getitng/setting methods,
on a LinkedList object in an application scope, which of its own, excludes
the page context.
See how ya go, but doen't overlook the reading I suggested,
even though your stuck, and it's old!
:)
I recommend submitting your resultset
----- Original Message -----
From: "Thufir" <hawat.thu...@gmail.com>
To: <ecs-user@jakarta.apache.org>
Sent: Tuesday, February 24, 2009 1:23 PM
Subject: custom Table
I think that the problem with this class is that setColumnNames and
setData aren't really setting attributes. I suppose I should make
instance attributes like "header" and "data"?
(luckily we're moving into JSP soon, but, still...)
also, is there a problem with passing ResultSet around to different
objects? I read that there's a problem with that.
package a00720398.html;
//adapted from oreilly sample in ch 16
// Java Servlet Programming, Second Edition
// http://oreilly.com/catalog/9780596000400/
import java.sql.*;
import org.apache.ecs.html.*;
public class ResultSetTable extends Table {
private static final boolean isPretty = true;
private ResultSet rst = null;
ResultSetMetaData rsmd = null;
public ResultSetTable() {
}
public ResultSetTable(ResultSet rst) throws SQLException {
this.rst = rst;
rsmd = rst.getMetaData();
setBorder(1);
setColumnNames();
setData();
}
public void setResultSet(ResultSet rst) throws SQLException {
this.rst = rst;
rsmd = rst.getMetaData();
}
private void setColumnNames() throws SQLException {
int colCount = rsmd.getColumnCount();
TR tr = new TR();
tr.setPrettyPrint(isPretty);
A a = new A();
a.setPrettyPrint(isPretty);
a.setHref("/Assignment?crud=D&row=0");
//<http://www.google.ca/search?q=doget
+url&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-
US:unofficial&client=firefox-a
a.addElement("delete");
TH colZero = new TH();
colZero.setPrettyPrint(isPretty);
colZero.addElement(a);
tr.addElement(colZero);
for (int i = 1; i <= colCount; i++) {
TH th = new TH();
th.setPrettyPrint(isPretty);
th.addElement(rsmd.getColumnLabel(i));
tr.addElement(th);
}
addElement(tr);
}
private void setData() throws SQLException {
int colCount = rsmd.getColumnCount();
TR tr = new TR();
//rst.beforeFirst();
while (rst.next()) {
tr = new TR();
tr.setPrettyPrint(isPretty);
for (int i = 1; i <= colCount; i++) {
TH th = new TH();
th.setPrettyPrint(isPretty);
th.addElement(rst.getString(i));
tr.addElement(th);
}
addElement(tr);
}
}
}
thanks,
Thufir
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscr...@jakarta.apache.org
For additional commands, e-mail: ecs-user-h...@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: ecs-user-unsubscr...@jakarta.apache.org
For additional commands, e-mail: ecs-user-h...@jakarta.apache.org