Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Javascript in JSP program ?

 
Ray Law
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ray Law
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ray Law
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic