• Post Reply Bookmark Topic Watch Topic
  • New Topic

Conditional use of script let tag in java script function

 
Gauravu Arorau
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using script let tag in java script function and i want to use that script let code conditionally.

My code snippet is as follows:

Currently, while loading the JSP both the SOP gets printed.

Thanks,
Gaurav

[BSouther: Added UBB CODE tags]
[ January 10, 2007: Message edited by: Ben Souther ]
 
pawank gupta
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use <%= %> tag instead
 
Anu Pillai
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its better to use javascript alert function inside javascript functions than using scriptlets
 
Robert Berg
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is correct behaviour. The condition you have there is evaluated at the client side, and not on the server side. And of course, the client needs all possible outcomes to react on this condition. What you are doing basically is providing the client with the necessary JavaScript source code.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of it this way:

There are at least two stages involved.
The JSP app writes your HTML and Javascript code.
It then streams that code to the client (browser) where it is interpreted.
By the time the client displays the HTML/Javascript, the JSP is finished.

A good habit to get into when starting out with web development is to always view the HTML source from your browser. That is the output from your JSP.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gauravu Arorau:
while loading the JSP both the SOP gets printed.


What is happening behind the scenes is that your JSP is being turned into a Java file, compiled and loaded. that's why its printing both SOP statements..

hope it make you clear..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this article for a better understanding of this issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!