This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JSP and the fly likes Difference in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Difference in JSP" Watch "Difference in JSP" New topic

Difference in JSP

Abhinav Sharma

Joined: Aug 08, 2001
Posts: 25
Hello everyone,
I know this is a kind a very stupid question. Cuz a person who has already done database connectivityis asking this question. But these are some very easy questions due to which i am not able to learn jsp properply. Can anyone tell me what is the difference between :-
When i say
Integer p=new Integer(12);
int u[]={1,2,3,4,5,6,7}
Whenever i add the Integer in the vector it adds it without any difficulty. But when we add int u[] it gives me error messege "No match was found for method." I am using a vector where i am storing string and integer both. I can store string which has more than one values but i cannot store integer more than one values. For that i have to store one value at a time. My question is that how can i store a integer array in a vector so that i can call it in a vector. As my vector consist both a string and Integer. I can store string array when i write :-
String st[]={"Abhinav :-","Bharat :- ","Shalini:- ","Abhay:-","Deepak :-","Farhan :-","Hanish :-","Jacob :-"};
And then add it in a vector
And later call it by
0th element is my string array.
Can i call a integer array also like my string array.
Thanks in advance
ted oniger

Joined: Aug 05, 2001
Posts: 16
Hi Sharma,
Since array (even array of primitive) is a special type of object and is a subclass of Object, therefore you can put in a vector.
You shouldn't have a problem adding the array of int in your vector. I have tried adding two arrays of int in a vector and it was OK.

int[] a = {1,2,3};
int[] b = {1,2,3};

Vector v = new Vector();
The code above compiled with no problem.
Hope this helps

Abhinav Sharma

Joined: Aug 08, 2001
Posts: 25
hi ted,
Thanks for reply. But my problem still not solved. Well you can add int[] in a vector. But the problem is how to display the values inside the int.
My code is like this :-
Integer p=new Integer(25);
int[] u = {1,2,3,4,5,6,7,8};
String st[]={"ID1 :- ","ID2 :- ","ID3 :- ","ID4 :- ","ID5 :- ","ID6 :- ","ID7 :-","ID8 :-"};
String st1[]={"Abhinav :- ","Bharat :- ", "Shalini:- ", "Abhay:- ", "Deepak :- ", "Farhan :- ","Hanish :- ", "Jacob :- "};

<% for(int i=0;i<st.length;i++){
Vector v=new Vector();
I have used the same method to display a string value. And it does not shows any error. But when i use the same method for the int to display the values. it gives me the foloowing error.
"Errors reported by compiler :/jsp/WEB-INF/jsp/ Error: No match was found for method "addElement(int)".
I can add it in vector but i cannot display it and if i use this to add the values in vecotr "v.addElement(u);". And then if i display the values then it shows me some thing like this "[I@2f1ad8". I hope my problem is more clear to you. Thanks again for taking pains to answer me.
I agree. Here's the link:
subject: Difference in JSP
jQuery in Action, 3rd edition