aspose file tools*
The moose likes JSP and the fly likes Assigning Java variable to javascript variable. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Assigning Java variable to javascript variable." Watch "Assigning Java variable to javascript variable." New topic
Author

Assigning Java variable to javascript variable.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 408

Hi All,

I have a list of objects. I am getting that list in jsp using request object.I want to fetch object from java list object then get a value from that object and assign it to a javascript variable. Is it possible? I have tried following code but Its not working. Also If it is possible how much time it will take if list size is 1500?




Pawan Chopra
SCJP - DuMmIeS mInD
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Pawan,

I have tried following code but Its not working


is useless and doesn't provide any clue to anybody here.

Check your HTML generated by the code ( View source of web browser) and see if you could figure it out.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Try this





scriptlet in jsp is discourage . set the value into anyscope on servlet . and use EL to read that . Here i use String "Hai"
for example .

Hope this helps
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
What you are trying to do is possible but not recommended. As seetharaman has told you, try to use EL
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
When debugging servlet/jsp/javascript applications it is helpful to use a browser such as FireFox with plugins which let you see EXACTLY what the browser request is actually getting and the JavaScript structures being created.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning Java variable to javascript variable.
 
Similar Threads
Object creation issue wiht Javascript.
JSP variable typical problem
DataTable inside a DataTable
MultiDimenaional Array sort
Submit dynamically created form with jQuery