You probably can't "pass the object"
and you probably don't need to.
Think about the systems that are running your code:
* servlet runner JVM/web server is executing the servlet
your JSP compiled into, connect to via HTTP requests/responses...
* web browser with javaScript interpreter running the javaSCript
and (maybe, maybe not activated and maybe soon not there)
JVM is running the java code and accessing java objects from
javaScript.
Do you really want to send a serialized
object or handle to a remote object
between your servlet runner's JVM, via the web server, to the
(maybe not there) JVM inside your web browser just so a javaScript
function can get access to a bunch of strings?
Why don't you just send the string data inside the properities object?
Cheers, Andy
-----Original Message-----
From: hua ge
To: [EMAIL PROTECTED]
Sent: 11/7/00 2:40 PM
Subject: how to call javascript function and pass class object to it i n
JSP?
Hi,
this is the sample code I try to pass a variable to javascript function
from
jsp. it works.
but if I try to pass Properties object prop to that function, it won't
work.
I like to know to pass the object?
<%@page import="java.util.*" %>
<% // the page is forwarded from another jsp page which
// set request.setAttribute("prop",value).
Properties prop = new Properties();
prop = (Properties)request.getAttribute("prop");
String name = prop.getProperty("name1");
%>
<html>
<head>
<title>MAMSI- Group Eligibility</title>
<script Language="JavaScript">
function go(name1)
{
alert("name=" + name1);
}
</script>
</head>
<body>
<a href="javascript:go('<%=name%>')"> click here to pass property </a>
</body>
</html
>From: Andy Purshottam <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: how to call javascript function and pass class object to
it i
> n JSP?
>Date: Tue, 7 Nov 2000 12:38:14 -0800
>
> Asnwering your question requires knowledge of
>where (client or server) you want to execute
>various pieces of code. the JSP page is run on the server,
>creating HTML with the link sent to the browser. Certainly the
>link can be a javscript: type URL, which calls a client side
>javascript function when the link is clicked. But where is the
>java Properties object coming from? The server side java code on the
JSP
>page? If so, you'd need to get the object somehow to the client,
>maybe in hidden fields, or via javaScript code in the <HEAD> of the
>generated HTML.
>
>Andy
>
>
>-----Original Message-----
>From: hua ge
>To: [EMAIL PROTECTED]
>Sent: 11/7/00 12:02 PM
>Subject: how to call javascript function and pass class object to it in
>JSP?
>
>hello,
>
>I have a jsp page, there is a link there, I want the link to call a
>javascript function and pass a java Properties object to that function.
>
>is that possible to do that?
>
>there is no problem for me to pass string, int data type to JavaScript
>function, I wondered is it possible to pass the Properties object to
>the
>javascript function, and retrive the Properties object attribute value
>in
>that function?
>
>
>
>thanks
>
>helen
>_______________________________________________________________________
_
>_
>Get Your Private, Free E-mail from MSN Hotmail at
>http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
>
>=======================================================================
=
>===
>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
________________________________________________________________________
_
Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
========================================================================
===
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