Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using javascript in a scriptlet

 
Ravissant Markandey
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

Can anyone please tell me how i can use a javascript variable in a scriplet? Heres what i want to do :


so, instead of the '107' i want to put a javascript variable, like :



Please note the above DOESNT work, how do i do it??


Regards,
RAvissant
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As far as I know, this would not work. I have this feeling as javascript actually runs at your client machine and servlet on your server. So servlet can't really access any variable declared under client side script. I may be completely wrong here and would love to know the facts here.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled on this topic and found the very first link

Passing Javascript variable to servlet.

Check that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64836
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article. It's about JSP, but the same applies to servlets.
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add the above comments.
You know we can write java code in the scriptlet.And in java code we can write Html code.And in html code we can write javascript......
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64836
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by raj malhotra:
Just to add the above comments.
You know we can write java code in the scriptlet.And in java code we can write Html code.And in html code we can write javascript......
Which has nothing at all to do with the original question. It still does not allow client-side values to be available in a non-causal fashion to code executing on the server long before the page is even sent to the browser.
 
raj malhotra
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr Bear Bibeault for correcting me
 
Ravissant Markandey
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ravi, Raj and Bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic