aspose file tools*
The moose likes JSP and the fly likes Question about Javascript in JSP program ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Question about Javascript in JSP program ?" Watch "Question about Javascript in JSP program ?" New topic
Author

Question about Javascript in JSP program ?

Ray Law
Greenhorn

Joined: Mar 30, 2005
Posts: 14
I am new in Java and JSP. In some case, Javascript help me to do some functions in JSP, so I want to know, is it common to embed javascript in JSP program in commercial environment? or I should try to code java Functions. Who has idea on it ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

They really have nothing to do with each other. Any Java in a JSP is executed on the server in order to format an HTML page to send to the browser. Any Javascript on this HTML page is interpreted by the browser just like any other HTML page.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ray Law
Greenhorn

Joined: Mar 30, 2005
Posts: 14
Thanks a lot. you mean that both (java and javascript) are common used in normal JSP programs, is it correct ?
Only one difference, Java is executed in server side, but Javascript is interpreted in client browser.
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
If you need to do something on the client such as showing messages in alerts etc. then you write in javascript.
javascript functions are loaded onto the client from server and they dont go back to server for execution.
Java gets executed on server side and not on client side.

This is the main difference.
just keep in mind

javascript----client-side
java/jsp/servelets --- server-side.


Life called,so here I am.<br />Cheers<br />Niki.:-)
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Ray Law:
Thanks a lot. you mean that both (java and javascript) are common used in normal JSP programs, is it correct ?
Only one difference, Java is executed in server side, but Javascript is interpreted in client browser.


That's right.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ray Law
Greenhorn

Joined: Mar 30, 2005
Posts: 14
Thanks and by the way, Do you know that Javabean is the best choice to handle data access functions, instead of java coding in JSP ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about Javascript in JSP program ?