aspose file tools*
The moose likes JSP and the fly likes how can i get a value in java script function from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how can i get a value in java script function from database" Watch "how can i get a value in java script function from database" New topic
Author

how can i get a value in java script function from database

abhishek paliwal
Greenhorn

Joined: Jun 25, 2005
Posts: 4
hii
is their any way to get some value from database to java script function?
i want to access a database value from database to java script function through jsp. but after so many effort i am unable to pass that value.
if u have any suggesions regarding to this problem then please send it.
actually i am execute a sql query in jsp for retrive data from database.but i can't able to send this value to my java script function for validations of that value.
if anyone have the solution then please send the solution of that problum with some sample code.
thankx in advance
i am waiting for replies
:abhishek paliwal
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can't 'pass' a value to a Javascript function from JSP because the two are running in different environments.

You use JSP to 'write' your javascript.
While doing so, you can write the value of your JSP variables as Javascript literals.



When you view the HTML source from the browser, you will JSP properties's value written to the source.
[ June 28, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
you can pass the values in the call to the javascript function
as


Use the above code for your purpose to full effect.

[ June 28, 2005: Message edited by: Niki Nono ]
[ June 28, 2005: Message edited by: Niki Nono ]

Life called,so here I am.<br />Cheers<br />Niki.:-)
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I think the misleading term here is "pass".
You never actually pass a value from one realm to the other.

The JSP code writes the Javascript code.
As far as the browser is concerned, there is no difference between a string literal, typed by hand, into a flat file and the result from a JSP expression tag.

It's all just text to the browser.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can i get a value in java script function from database
 
Similar Threads
Java JSP Design Issue
calling a javascript function in jsp
To change the color of the text box from where some error rises
JSP and JavaScript
passing jsp variable to java script function on same page