• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP in JavaScript

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • 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
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, this is one solution....
document.write('<% out.print("erik"); %>');
Erik
 
Jayson Falkner
Author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!