On Wed, 4 Sep 2002, Chetan K.R wrote: > Hi all, > > I need to pass the value of a JS variable to a JSP method > > The JSP is enclosed inside <script> tag > > The value returned by JSP is used for some purpose in JS > > Any idea how to do it ?
There is no direct interface between JSP and JavaScript. The browser receives JavaScript from the server only as text, so there isn't any way to pass a structured object, as in <script> javaScriptFunction(<%= myDate %>); </script> Instead, if you want to pass data from JSP to JavaScript, you need to construct the appropriate JavaScript literals in text, or build up appropriate assignments. If you've got strings, then this is easy, but if you're trying to initialize more complex objects, you need to do so with combinations of individual assignments and literals. -- Shawn Bayern "JSTL in Action" http://www.jstlbook.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com