Jim wrote: > I have posted this and nobody has responded. Yes, they have. Kwok, Craig, Triptpal, Peter and David all replied to your previous posts on this subject. In particular, Craig's reply on 11/14 listed some possible problems and asked to see the get/set methods in the base class. The fact that this starts working when you use _other_ method names probably means that there is something wrong with the existing methods. I don't see where you have posted code from the base class yet. That might help. At this point, I would start over and write a tag containing only those two attributes in a new, empty webapp. Leave out any database access, just have it print something simple. If it still does not behave properly, then you'll be able to post a complete example that people can help you debug. More than likely, you'll find the problem yourself as you go through the exercise of stripping it down to the simplest program that works and demonstrates the problem. -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University PA Information Resources Management
On Tue, 19 Nov 2002, Jim Cobban wrote: > Furthermore I have received a reply from another user that he encountered > the same problem with an attribute "class" which he had to rename to "clasz" > in order to get it to work. FYI, this is because the java.lang.Object class (superclass of all Java objects) has a getClass() method already. Basically, that makes it tedious to impossible to use "class" as a property name. Craig -- To unsubscribe, e-mail: <ma...@jakarta.apache.org> For additional commands, e-mail: <ma...@jakarta.apache.org>
----- Original Message -----
From: "Wendy Smoak" <We...@asu.edu>
Subject: RE: Please respond, I am at a roadblock, Tomcat cannot find sette r
method
> In particular, Craig's reply on 11/14 listed some possible problems and
> asked to see the get/set methods in the base class. The fact that this
> starts working when you use _other_ method names probably means that there
> is something wrong with the existing methods. I don't see where you have
> posted code from the base class yet. That might help.
I did post the code of the set methods in the base class.
Furthermore I have received a reply from another user that he encountered
the same problem with an attribute "class" which he had to rename to "clasz"
in order to get it to work.
The ONLY thing I changed between the version that failed and the version
that worked was the names of the attributes and the corresponding set
methods. I did not change one character of the code in the methods. If
you are not satisfied with that here is the entire base class with nothing
changed but the names of the set methods:
/**
* QueryTag.java
*
* This tag implements a query of the census data database and encapsulates
* a tabular display of the data. This is the base class for tag classes
* which will exploit the row tag and field tag to display the results of
* a query. In order to use the row tag the first two fields requested in
the
* SELECT verb must be the district number and the subdistrict identifier
* since the class RowTag assumes that in order to extract the county
* identifier and subdistrict name from the subdistrict table.
*
* © 2002 James Cobban
*/
package Census.tags;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.sql.*;
import Census.ConnectionPool;
public class QueryTag extends TagSupport
{
static protected final int ENGLISH = 0;
static protected final int FRENCH = 1;
private int Language;
static private final String[] LangCode = {"En", "Fr"};
// LangTag.setLang
//
// handles an attribute which sets the language to be used in text
// displayed to the user
public void setLing(String lang)
{
if ((lang != null) && lang.equalsIgnoreCase("FR"))
Language = FRENCH;
else
Language = ENGLISH;
} // LangTag.setLang
public int getLang()
{
return Language;
}
public String getLangCode()
{
return LangCode[Language];
}
// local members of the class
// limit on number of rows to display
private int maxRows = 50;
// QueryTag.setMaxRows
//
// handles an attribute which sets the maximum number of rows to display
// from the database
public void setMaxRoz(String repeats)
{
try
{
maxRows = Integer.parseInt(repeats);
}
catch(NumberFormatException nfe)
{
maxRows = 50;
}
} // QueryTag.setMaxRows
// QueryTag.getMaxRows
//
// returns the maximum number of rows to display
public int getMaxRows()
{
return maxRows;
}
protected String where; // the where clause of the query
protected ConnectionPool connectionPool;
protected Connection connection;
public Connection getConnection()
{
return connection;
}
protected int rowCount; // number of rows in the result
public int getRowCount()
{
return rowCount;
}
protected int row; // starting row in the result
public int getRow()
{
return row;
}
protected String pageName; // page this tag is on
public String getPageName()
{
return pageName;
}
protected ResultSet resultSet; // result of query
public ResultSet getResultSet()
{
return resultSet;
}
// QueryTag.addParmToWhere
//
// This method performs standard actions to add a search argument to
// the "where" clause of the query
protected void addParmToWhere(ServletRequest request,
String parmName,
String dbName)
{
String value = request.getParameter(parmName);
if ((value != null) && (value.length() > 0))
{ // parameter supplied
if (!value.equalsIgnoreCase("Any"))
{
if (where.length() > 0)
where += " AND ";
where += dbName + "=\"" + value + "\"";
}
} // parameter supplied
} // QueryTag.addParmToWhere
// QueryTag.addIntParmToWhere
//
// This method performs standard actions to add a numeric search
argument
// to the "where" clause of the query
//
// Returns: numeric value of parameter
protected int addIntParmToWhere(ServletRequest request,
String parmName,
String dbName)
throws NumberFormatException
{
int rc = 0;
String value = request.getParameter(parmName);
if ((value != null) && (value.length() > 0))
{
if (where.length() > 0)
where += " AND ";
where += dbName + "=" + value;
rc = Integer.parseInt(value);
}
return rc;
} // QueryTag.addIntParmToWhere
// QueryTag.getRow
//
// This method gets the row number in the response at which display is
to
// start. As a side effect it sets the "row" member so that the public
// getRow method will work. It must be called by the doStartTag method
// to perform that initialization.
protected int getRow(ServletRequest request)
{
String Row = request.getParameter("Row");
if ((Row != null) && (Row.length() > 0))
{ // the Row parameter was specified
try
{ // convert the string to integer
row = Integer.parseInt(Row);
} // convert the string to integer
catch(NumberFormatException ne)
{ // invalid format
System.out.println("Row parameter not numeric");
row = 0;
} // invalid format
return row;
} // the Row parameter was specified
return 0;
} // QueryTag.getRow
} // class QueryTag
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Thank you for your assistance. I do not know exactly what Tomcat is looking for, but once I renamed the get methods that returned int values (because that is what the internal logic of my app required) so that all that the compiler saw was the setLang method, it accepted that as the setter method. Why the signature of the get method had anything to do with it is beyond me. -- To unsubscribe, e-mail: <ma...@jakarta.apache.org> For additional commands, e-mail: <ma...@jakarta.apache.org>