• 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

JSP in JavaScript

 
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to dynamically include some JSP in my Javascript,
but I can't get the syntax to work.
For example, Here is a simple Javascript:
document.write(" <% out.println("hello") %> ")
Can anyone help me out with this?
My real goal is to be able to include a JSP file in the Javscript:
document.write("<@ include file="myHTML.jsp" %> ")
Thanks,
Drew
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, this is one solution....
document.write('<% out.print("erik"); %>');
Erik
 
Author
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question looks a bit off? JSP executes on the server-side. You are talking about client-side JavaScript. In this sense writing out some JSP syntax to the client's browser will do nothing.
http://www.jspinsider.com/faq/2.view
However, you can have a JSP generate your JavaScript. Is this what you are trying to do?
 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys,
I finally got it working by using JSP to generate the Javascript instead of trying to insert the JSP in the Javascript.
Regards,
Drew
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I've done this. Basic rule: try not to.
I has a JSP writing out Javascript which drove some DHTML.
Glad I'm not the one who had to maintain that sucker
Dave
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic