But that's not *really* accessing a bean from javascript. The server will
process the page first, replacing <%=Password.getPassword()%> with the
password value. It would look something like this after processing:

if(document.password.newpassword.value == "passwd")

When the javascript function is called, it only looks at the client-side
page. The difference is java is server-side, and javascript is client-side
(usually).

Dave


----- Original Message -----
From: Dawei Jiang <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 11, 2001 2:05 PM
Subject: Re: Can JavaScript access JavaBeans?


> You can  access java bean from javascript function like this:
> --example-----------------------------------------------------------------
--
> ---
> <jsp:useBean id="Password" scope="request"
> class="com.myproject.PasswordBean" />
> <SCRIPT LANGUAGE="JavaScript">
> function validatePassword()
> {
>   var returnValue = true;
>   if (document.password.newpassword.value == <%=Password.getPassword()%>)
>
>
>     alert("You must enter a different one!");
>     returnValue = false;
>   }
>   return returnValue;
> }
> </SCRIPT>
> --------------------------------------------------------------------------
--
> ----
>
>
> D. Jiang
> Sun Certified Java Programmer
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of giri punn
> Sent: Thursday, January 11, 2001 12:52 PM
> To: [EMAIL PROTECTED]
> Subject: Can JavaScript access JavaBeans?
>
>
> Hi,
>
> I want to access javabean from a javascript function? please let me know
if
> this is possible?
>
> thanks,
> giri
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.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://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".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> 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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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