This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

performance issue of Vector

 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a webpage. where i am displaying my data in a jsp page. i have used Vector to fetch the data from the databases.

But once when more number of users try to access the page.. the Vector doesnt work.

is it a better or good way to use vector in webpages.
pls reply
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use an ArrayList instead of a Vector but that shouldn't cause problems. What exactly does "does not work" mean"? How are you using the Vector? Could you give us a code snippet or two?
 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,

I have a JSP page. from there i am accessing a java File. There i will fetch the Data's from the DB and set it into a Vector and pass the same to the JSP page for the Display.

The method in the java file is not synchronised.

when the page gets more number of hits .. then the array returned in empty
vector[] and so i am getting a exception in the JSP page.
(why bcos i am accessing the Vector in the JSP to show up data's) so when a null vector is access using vector.get(i) (where i is loop variable)

i am getting "java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1 "

Exception

can u pls help me out???

Thanks
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think it is a vector performance issue. can you pls paste the code snippet and a scenario in which it fails???
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the Vector static or an instance variable of the servlet? Without some code snippets I don't think we will be able to help.
 
Giovanni De Stefano
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...just forget Vector, use ArrayList instead, and post your code.

Giovanni
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic