Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

in jsp where javascript code exected?

 
Sweety S.
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i write jsp in that jsp i have done all validation using javascript.so when clint request through browser where that script exected on client side or server side?if client side then if my browser doesnot support java script validation what happen?
pl.reply
thank in advance
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP code ( the stuff in <% %> ) is executed when the page is being built, befor eit is sent to the browser. JavaScript is executed on the browser, long after the page has been built and sent over the network.
You may be getting confused by seeing JavaScript code in amongst the HTML in a JSP. The thing to always remember is that, to JSP, JavaScript is just text which the JSP sends to the browser. JSP neither know nor cares the difference between HTML and JavaScript - it just bulds it and sends it to the browser.
[ March 03, 2004: Message edited by: Frank Carver ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sweety,

i write jsp in that jsp i have done all validation using javascript.so when clint request through browser where that script exected on client side or server side?

Although the JavaScript is generated by JSP in server, JavaScript ALWAYS being executed in client browser.

if client side then if my browser doesnot support java script validation what happen?

In this case, all JavaScript will NOT be executed, and all checkings will not be performed. Thus, in practice, we will do one more layer.
We first check the input from the users in the browser via JavaScript, we will also check it once again in the server-side (say Servlets) before the data is really put into the database or being process.
This is because, when JavaScript is disabled, the checking will be by-passed, and invalid data can be sent to the server which may harm the server. Thus, being doing anything, we will check it once again.
You may think that, if we check it 2 times, then, maybe the checking in browser can be removed. But this may not be the case. Since JavaScript can prompt the user immediately if the enter the wrong data. Thus, this saves the network bandwidth that every time, wrong data are only triggered by the server component.
Does this help you?
Nick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic