Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using javascript in a scriptlet  RSS feed

 
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
 
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.
 
Author and ninkuma
Marshal
Posts: 66677
167
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.
 
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
Posts: 66677
167
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
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!