• 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

Passing String[] from jsp to applet

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I pass a String[] variable from an sjp or html page to applet. How do I access the parameter inside the applet. As I know, getParameter() returns only String.
What should be done to pass Object from jsp to Applet?
Thanks.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi pavan,
i tried the following code and it worked fine with me,

i called this Javascript function onload event of the body. i use simple applet tag here with the html file having only one applet in it- testapplet.

it produced the output - Maulin H Vasavada in the textarea.
let me know if it works for you. i am using Netscape7.0.
regards
maulin
 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maulin.
Without calling the applet's method, is there no other way to do this? Actually, I am getting String[] from servlet which is to be passed to applet from the html file (Servlet redirects the request to html page containing the applet). Any thoughts(without javascript)?
In the servlet, I use request.setAttribute() and in the html page I request.getAttribute() the object. How can I pass the object present in html page to applet without javascript.
Thanks.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi pavan,
well, in that case its difficult because as u mentioned we can't use applet's param tag to pass an array...
but there is a workaround...its wiered but u know its like that...
1. after recieving String[] from the servlet you convert that into comma separated list and then pass that in the applet's param tag as a parameter
2. in applet again convert it back into String[]
...does this sound good? though this would require little processing to convert String[] into comma separated values and then converting it back to String[] in the applet. may be you can embed comma separated values only in the Servlet's setAttribute() so that u can get rid of first conversion here (if this doesn't affect your applications other parts)
regards
maulin
 
reply
    Bookmark Topic Watch Topic
  • New Topic