• Post Reply 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

Calling JSP scriptlet on basis of Javascript condition

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Thanks in advance.
I am facing with some issue please help me.
Actually I have some code of JSP scriptlet should be executed on basis of Javascript condition like,

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No you can't do it because javascript and jsp are for totally different purposes.

Javascript is client side language and jsp is a server side language.

You can use custom tags to conditionally set attribute in a session object.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sreedhar Lackka wrote:
the Session attribute should be set only when I call that f()



in this condition when you call the particular function ,you can set the session on server side also
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your reply.
Could you please give me any example code.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java/JSP runs at the server machine.
Java/JSP generates HTML/CSS/JS output.
Server machine sends HTML/CSS/JS output to the client machine.
Client machine retrieves HTML/CSS/JS and starts to interpret/run it.

View a JSP page in your webbrowser. All you see is HTML/CSS/JS. No scriptlets, no taglibs, no EL.

Whenever you want to run JS using Java/JSP, simply print it out. E.g. <script>var = '${foo}';</script>.
Whenever you want to run Java using JS, simply invoke a request from the client to the server. You can use window.location, form.submit() or new XmlHttpRequest() for this.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this article to understand how JSPs operate.
reply
    Bookmark Topic Watch Topic
  • New Topic