• 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

Question about Javascript in JSP program ?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
I brought this back from the farm where they grow the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic