• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing String[] from jsp to applet

 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • 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.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!