File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes in jsp where javascript code exected? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "in jsp where javascript code exected?" Watch "in jsp where javascript code exected?" New topic
Author

in jsp where javascript code exected?

Sweety S.
Greenhorn

Joined: Feb 26, 2004
Posts: 9
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

Joined: Jan 07, 1999
Posts: 6920
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 ]

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: in jsp where javascript code exected?