Once again, always remember that JavaScript and JSP live in two different
worlds, and execute in different places and at different times. The JSP is
processed on the server and it's what creates the HTML (including
JavaScript) which is then sent to the browser. JavaScript lives in the HTML
and on the browser, which is where it gets executed. The Java code and the
JavaScript code can't be mixed, which is what you were trying to do. You had
some JavaScript in which you were concatenating a Java string.

It can get confusing, admittedly, and I've found that it helps me to always
think in terms of the Java code and consider the JavaScript as being
generated. This is the one place where I think it's ok to use out.println;
the parameter to that is a Java String in which you can freely concatenate
other Java things. The only thing to watch for is making sure you escape the
quotes that are in the JavaScript. So, for example, to create the line you
have below, you can do this:

out.println("var cCW = window.open(\"/addinfo/currency.html?price=" + string
+ "\",\"currencyConverter\",\"HEIGHT=400,WIDTH=400\");");

where string is the name of a Java variable. If the value of string is "75",
then you'll end up with this in your HTML:

var cCW =
window.open("/addinfo/currency.html?price=75","currencyConverter","HEIGHT=40
0,WIDTH=400");

--Jim Preston


-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Caspar van Vroonhoven
Sent: Friday, August 04, 2000 8:58 AM
To: [EMAIL PROTECTED]
Subject: Javascript + JSP + Including


Hey everyone,


I've got a little question about using Javascript and JSP together..:

How can I include parameters (..<here he goes again :-)>..) in a window
constructed by window.open in javascript...
This particular parameter is requested at the page where the javascript is,
so the real question is how to get a JSP string into a javascript one, so
that it can be put in my statement (if at all possible) like this:

 var cCW = window.open("/addinfo/currency.html?price=" + string +
","currencyConverter","HEIGHT=400,WIDTH=400");

where the string is supplied by jsp..
copying the whole <%= ..... %> thing doesn't work, I already tried that..

TIA,

Caspar van Vroonhoven
www.tradingcars.com
Amsterdam, The Netherlands

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to