fpoyavo
asked on
applet to jsp
Hi Experts,
I have applet running within my jsp. I pass some param.
<param name="CustID" value="1">
How can I retrieve this param CustID back from APPLET ?
Thank you.
I have applet running within my jsp. I pass some param.
<param name="CustID" value="1">
How can I retrieve this param CustID back from APPLET ?
Thank you.
you can use js to call the applet to return the parameter but why would u need to as the jsp page already has the value?
ASKER
The problem is that this applet when it is used by the user may modify this CustID ...so I need to know the new one.
How exactly I can do that ?
How exactly I can do that ?
Add a public method to your applet to return the custid, and call the applet from js to retrieve it.
ASKER
Objects,
You are the best. May you give me some simple code sample ?
Thank you.
You are the best. May you give me some simple code sample ?
Thank you.
ASKER
I need to get this CustID whenever user clicks within applet area.
> I need to get this CustID whenever user clicks within applet area.
for what purpose? what do u need to do with the value
for what purpose? what do u need to do with the value
ASKER
I need it to process another jsp.
Please.
Please.
But why do you need it everytime user clicks within applet?
ASKER
:) objects. just help me and don't ask me why.
Was just asking because it may affect the way you achieve it :)
You should either call the applet using javascript,
or have the applet call a javascript function.
Whichever is most appropriate in your situation.
You should either call the applet using javascript,
or have the applet call a javascript function.
Whichever is most appropriate in your situation.
ASKER
I was trying to do that:
like you adviced :
in my javascript which I have tried to run directly and from .js
function getnewid()
{
var newid = document.myApplet.appletme thod();
alert ("here it is : " + newid);
}
it is in <img src="mybutton.gif" onclick="getnewid();">
when I click nothing is happening...no errors no nothing. I have inserted MAYSCRIPT in the CODE line but nothing is going on.
Hmmmm. ??? Please .
like you adviced :
in my javascript which I have tried to run directly and from .js
function getnewid()
{
var newid = document.myApplet.appletme
alert ("here it is : " + newid);
}
it is in <img src="mybutton.gif" onclick="getnewid();">
when I click nothing is happening...no errors no nothing. I have inserted MAYSCRIPT in the CODE line but nothing is going on.
Hmmmm. ??? Please .
ASKER
It actually give a warning in line where my <img> that object is expected when I click on image.
ASKER
I have puted just alert("javascript is started") in onclick event and it does not show up. What the .... is this ?
Perhaps img tag does not support onclick, test with:
function getnewid()
{
alert ("Here");
}
function getnewid()
{
alert ("Here");
}
ASKER
Ok. I see you trying to drive me crazy :) bye. Wish you luck. IMG always supported onclick and I hope you are kidding :)
PLEASE CLOSE THIS QUESTION.
PLEASE CLOSE THIS QUESTION.
if you use the function I posted above does the alert() get displayed?
ASKER
Objects :),
I told you that I was trying it and there is no alert.
May be it has to do with JSP ?
forget about it.
I told you that I was trying it and there is no alert.
May be it has to do with JSP ?
forget about it.
try to change you name of applet form myApplet to myapplet (all lowercase). or use document.applets[0]
make sure the method name must be exactly the same as you defined in applet, case sensitive.
http://www.apl.jhu.edu/~hall/java/Java-from-JavaScript.html
http://www.apl.jhu.edu/~hall/CWP-Sources/CWP-Examples/Chapter19/MoldSimulation.html (view source)
make sure the method name must be exactly the same as you defined in applet, case sensitive.
http://www.apl.jhu.edu/~hall/java/Java-from-JavaScript.html
http://www.apl.jhu.edu/~hall/CWP-Sources/CWP-Examples/Chapter19/MoldSimulation.html (view source)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and more examples:
http://www.codeguru.com/java/Applet/Javascript-LiveConnect/index.shtml
http://www.codeguru.com/java/Applet/Javascript-LiveConnect/index.shtml
ASKER
Thanks a lot. Great sample.
glad to know and my pleasure :-)