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

invoke java method from java script function

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Is there any way to call a java method from java script funtions on the basis of some condition?

Thanks
Gaurav
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Gauravu,
This question is close enough to:
https://coderanch.com/t/291249/JSP/java/Conditional-script-let-tag-java
that I think it would be better to continue the discussion there.

The answer is the same as the ones given there.
Javascript is interpreted on the client's machine, in a browser.
JSP is interpreted on the server and is, in effect, done and finished before the Javascript even starts.
For this reason, there is no way to conditionally execute JSP code based on branches in your Javascript.

One workaround to this is AJAX but I wouldn't recommend tinkering with AJAX until you have a firm grip on HTTP; at least as far as understanding what happens on the server and what happens on the client.

If you have any further questions, ask in your other thread.

-Ben
[ January 10, 2007: Message edited by: Ben Souther ]
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic