Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling JSP scriptlet on basis of Javascript condition  RSS feed

 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • 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,

 
gurneeraj singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks a lot for your reply.
Could you please give me any example code.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article to understand how JSPs operate.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!