• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can i transfer multiple values from applet to servlet

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to know how can i transfer multiple values from applet to servlet.Am successful in transferring single value but don't know about multiple.Can i transfer array of string this way from applet?:

String ar[]={fname,uname};
URLConnection con = getServletConnection1();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(ar);
oos.flush();
oos.close();

BUT HOW ABOUT in server side:

I have this over there:in servlet(This will definitely not work.This servlet code i made for accepting single string value)
What are the changes i should do in servlet code for accepting my string array from applet ?

InputStream in = request.getInputStream();
ObjectInputStream inputFromApplet = new ObjectInputStream(in);
String answer = (String) inputFromApplet.readObject();
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can send a String that way, then you can send an array of Strings just the same way. Of course you would have to cast the result to a String array in your servlet...
 
A Bhat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
will it be this in servlet?

String[] ar = (String[]) inputFromApplet.readObject();

If so,then how to read the values ar[0] for 1st value
ar[1] for next??

 
reply
    Bookmark Topic Watch Topic
  • New Topic