wood burning stoves 2.0*
The moose likes Servlets and the fly likes Vector from bean to servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Vector from bean to servlet?" Watch "Vector from bean to servlet?" New topic
Author

Vector from bean to servlet?

Ram Luchman
Greenhorn

Joined: Mar 30, 2002
Posts: 1
I'm getting nullpointer exception when I pass a resultset turned into vector from a bean to a servlet. I can pass the vector from the bean to a JSP page without problems. My code below. The error happens at this point "rs = (Vector)d.getQueryresult();"
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

One minor point, you shouldn't need to cast (Vector), because the return type of the method is a Vector.

The other thing is when you are building your query, you don't leave a space between the tablename and the WHERE clause.

If you printed the contents of the String 'q', you'd get "SELECT * FROM EmployeesWHERE userID = etc, etc...

Your try-catch-finally in your bean appears to be good, so I'd expect you would find the SQLException stack trace in your log. the 'return v' is in your finally block, so that should be ok.

What about the stack trace you do see? Can you post it?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

wait, it's not in the finally block.

In the bean class, the line that would throw the exception from a malformed query string is:

rs = st.executeQuery(query);

but only after that do you make the new vector.

v = new Vector();

Then below, when you attempt:

v.trimToSize(); This line should throw a NullPointerException
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector from bean to servlet?