aspose file tools*
The moose likes Servlets and the fly likes getting rid of nulls jsp/beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getting rid of nulls jsp/beans" Watch "getting rid of nulls jsp/beans" New topic
Author

getting rid of nulls jsp/beans

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Sep 21, 2001
Posts: 57
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

Joined: Mar 22, 2000
Posts: 12821
    
    5
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

Joined: Sep 21, 2001
Posts: 57
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
 
subject: getting rid of nulls jsp/beans