Click to See Complete Forum and Search --> : Strange Class error


Ebola
02-17-2006, 07:25 AM
I'm using java servlets to create a webpage, and since I'm used to working with PHP I'm trying to mimic include_once's.

String output ="";
output = sections.top(0);

Is what I use on the index page, and in the sections class, I have this code:

public String top(int LOG) {
//LOG is Log In Status, 1 is logged in, 0 is not.
String top2 = "";
if(LOG == 0){
top2 = "...HTML here....";
return top2;
}

When I try to view the page I get a "java.lang.NullPointerException" and I just can't figure out why. Can anyone help me out here?

Khalid Ali
02-17-2006, 11:33 AM
There could be manythings which may be causing this, post full code of your servlet and if applicable, mention what parameters are passed to servlet(af any)

sleven
02-17-2006, 01:13 PM
maybe you lose

sections = new sections();

Ebola
02-20-2006, 09:29 AM
Ah, that was it Sleven, thanks.