Bookmark Topic Watch 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis
  • Mark post as helpful
  • send pies
  • Report post to moderator
A lot of questions get asked in the JSP forum about mixing JSP and JavaScript. The simple answer is that it just cannot be done!

JSP is a server-side templating system that creates an HTML page (or other text document) on the server. Anything in this page that is not a JSP action or directive is simply template text that is ignored. HTML, CSS, and JavaScript code is just so much gobble-dee-gook to the JSP engine. It doesn't know anything about it, and it is simply passed into the response as is.

Once the HTML page has been formatted, it is sent to the client (usually a browser) for evaluation and display. All JSP-ness is completely gone at this point.

It is at the browser that the JavaScript is evaluated. And the browser doesn't even know that the page was generated by a JSP, let alone interact with it.

So, the JSP executes on the server and doesn't pay any attention whatsoever to JavaScript code and other page markup. And the JavaScript executes on the client, where even the fact that JSP is being used is unknown.

Never shall they meet! It's even worse than Romeo and Juliet, who at least got to get it on for a short time.

For more information about exactly how a JSP is processed, read The Secret Life of Java Server Pages


JspFaq
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!