JavaScript only works at client side, I mean, when the page arrives to the browser. JSP works at the server, so you can, of course add JavaScript code in your JSP but it will be executed when the page gets rendered at the browser. To add JavaScript in JSP just add the html tags to do it. For example:
// THIS IS A JSP PAGE <html> <head> <script language=JavaScript src="JavaScriptFile.js" <script/> <script language=JavaScript > funtion setItem(ItemValue) document.forms[0].Item.value= 'BLABLA' </script> </head> <body> <% jsp scriptlet with java code %> <% if request.getParameter("Param1").equals("VALUE") { %> <script language=JavaScript> alert("Param1 has been set") document.forms[1].Item3.selectedIndex=1 </script> <% } %> <% ...more java code %> </body> </html> // END OF JSP PAGE As you see you can combine the code as you will. The static code will be rendered always but that inside de if will be rendered only if Param1's value is "VALUE". Hope this helps > -----Mensaje original----- > De: SUBSCRIBE JSP-INTEREST Lennie Gu [SMTP:[EMAIL PROTECTED]] > Enviado el: sábado 13 de julio de 2002 2:21 > Para: [EMAIL PROTECTED] > Asunto: source javascript in JSP > > I know we can import external javascript in html pages. But I tried to > import the javascript in JSP, it seems that it can't work. May I know is > it posible to do it? how should I do it? I need the javascript to do > some common input validations. Thanks. > > ========================================================================== > = > 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 ==========================================================================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