File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting rid of nulls jsp/beans

 
rich werth
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i'm trying to get rid of nulls passed in from a dataBase.
I try a few variations of this but i always get an error. I usually get method getRemovenull not found in class. Can anyone help me out with this i'm new and not even really sure if I'm going about this the right way......thanks
My jsp looks something like this....
<%@ page import="java.sql.*, java.util.* " %>
<%@ page import="remove_nulls" %>
<jsp:useBean id="cart" class="remove_nulls" />
String ename = (cart.getRemovenull(eresults.getString("FIRSTNAME"));
<td width="7%"><%= ename %></td>
my bean looks something like this
public class remove_nulls{
private String data_in;
public String getRemove_null(String data_passed_in) {
data_in = data_passed_in;
if (data_in == null) {
return ""; // remove null
}
else {
return data_in; // return data
}
} // end method to resolve nulls
}
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
String ename = (cart.getRemovenull(eresults.getString("FIRSTNAME"));

Shouldn't it be getRemove_null, not getRemovenull?
------------------
Miftah Khan
- Sun Certified Programmer for the Java 2 Platform
- Sun Certified Web Component Developer for the J2EE Platform
 
rich werth
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry it actually is that. and I still get the error. I typed in the code and didn't cut n paste.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has got to be one of the most common bean problems.
You can NOT use just the class name in these tags:
<%@ page import="remove_nulls" %>
<jsp:useBean id="cart" class="remove_nulls" />
Your class MUST be in a package and the package MUST be named in the tags:
<%@ page import="mypackage" %>
<jsp:useBean id="cart" class="mypackage.remove_nulls" />
Your class will then have to be in
...WEB-INF\classes\mypackage\
or in a jar file in
...WEB-INF\lib\
If not, Tomcat tries to find the class in the "current directory" which is certainly not where you put the class file.
Bill
------------------
author of:
 
rich werth
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
the problem was with WebSphere. Well it was with me not restarting webSphere every time I changed the bean. But it works now.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic