This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes In Collection Vector problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "In Collection Vector problem" Watch "In Collection Vector problem" New topic
Author

In Collection Vector problem

mamidi venkat
Ranch Hand

Joined: Jul 03, 2007
Posts: 62
HI ALL,

Vector vtBB1= (Vector)request.getAttribute("vtBB1");
here iam getting object from the database and converting it to Vector

firs time its showing null whenever i open the page i.e
System.out.println(vtBB1);

My problem here is
int i=vtBB1.size();
whenever iam checking the condition(i<=0)

its showing null pointer exception in jboss server.how to reslove this.
suresh mulagala
Ranch Hand

Joined: Feb 18, 2003
Posts: 41
There could be many reasons why the vector is null in the request. Check if you are doing the setAttribute properly in the page where you are setting on to the request.

Its clearly screaming that vtBB1 is null and you need to find out why....
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8142
    
  52

At this point, this looks more like a JiG(B) or a Servlet question, than a JBoss question. Going by your

Vector vtBB1= (Vector)request.getAttribute("vtBB1");


code, i believe this will make more sense in the Servlets forum. Moving it there.


[My Blog] [JavaRanch Journal]
Gaurav Sharma
Greenhorn

Joined: Jan 30, 2007
Posts: 28
Hi

Its obvious that if null "Object" is returned from Database then checking the size of null will definetly return "NullPpointerException".

Then please check if vtBB1 is not null then only check for its size.
Rest you can code what I have written.

Please correct me If i am wrong!

Cheers!
Gaurav
suresh mulagala
Ranch Hand

Joined: Feb 18, 2003
Posts: 41
i would have thought that you are trying to retrive the vectory from the request and not the database...wise to see where you are putting in the request properly..
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Jaikiran Pai:
At this point, this looks more like a JiG(B) or a Servlet question, than a JBoss question. Going by your



code, i believe this will make more sense in the Servlets forum. Moving it there.


Moving


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: In Collection Vector problem
 
Similar Threads
ClassCastException
Datatable problem
question on in memory find criteria
Validate if vector is null
regarding check boxes