This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

JavaRanch » Java Forums » Java » JSP
Bookmark "Assigning Java variable to javascript variable." Watch "Assigning Java variable to javascript variable." New topic

Assigning Java variable to javascript variable.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

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
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


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: 299
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

Joined: Mar 22, 2000
Posts: 13001
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.

I agree. Here's the link:
subject: Assigning Java variable to javascript variable.
It's not a secret anymore!