• 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

Conditional use of script let tag in java script function

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use <%= %> tag instead
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its better to use javascript alert function inside javascript functions than using scriptlets
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
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 for a better understanding of this issue.
 
reply
    Bookmark Topic Watch Topic
  • New Topic