• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending an Array to a Servlet

 
Gayathri Neti
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a standalone client which invokes a Servlet.
I want to send an INTEGER ARRAY as a parameter to the Servlet. Can I do that?
If so, can anybody show me how??
Thanks
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey
Try using streams. either ByteArrayOutput or ObjectOutput ....
From client I guess you are making URLConnection to the servlet. So, once you have the URLConnection object do connection.writeObject(); and on the servlet side do request.readObject(); look on google for this kind of URLConnection examples..
Regards
Maulin
 
Gayathri Neti
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were passing the INTEGER ARRAY alone that might have worked fine.
I am passing 4 parameters. One of them is an INTEGER ARRAY.
Here is the code that I have:
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Maulin said, you could do this with object serialization. Look at the API for java.io.ObjectOutputStream and ObjectInputStream. Arrays of primitives and Strings are automatically Serializable as are Collections.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic