JSP is a SERVER side technology. JavaScript is CLIENT side. So..in that
regard, JSP has NOTHING to do with JavaScript. However, if you are
referring to how a JSP engine parses a JSP page and if it supports
JavaScript, I can assure you it works fine. I use JavaScript form
validation on our site and there is no problem at all.

However, you cant do something like so:

<html><head>
<script language="javascript">

function js_function()
{
  alert("JSP calling JavaScript");
}

</script>
</head>
<body>

<%
  if( request.getParameter("some_value") )
    js_function();
%>

</body>
</html>


This WONT work. Your JSP scriplet cant call a javascript function. However
you can do something like this:

<%
  if( request.getParameter("some_value") )
  {
%>
  <script language="javascript">
    js_function();
  </script>
<%
  }
%>

This will basically put that SCRIPT code IN the returned HTML page and call
the function "assuming" that the condition of "some_value" exists in the
request object. You have to keep in mind how JSP works. The first time you
access it, its turned into a servlet. THEN, and from then on, its accessed
no differently than a servlet. So, the first request to the JSP page passes
the request to your servlet, and more than likely (unless coming from
another page that set request "some_value" parameter) "some_value" wont
exist at that point. SO..the first request would NOT show the JS script
code, and the js_function() wouldn't be called. Now, if you have a form,
say with a hidden variable called "some_value" and you submit the form back
to the same JSP URI, at that point it WOULD find the "some_value" in the
request object, and the returned page to the browser would now include the
js_function() script call.



Kevin Duffey
Software Engineer
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to