Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to send arraylist from jsp to javascript(same page)  RSS feed

 
ritesh padhe
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
I want to send arraylist from jsp to javascript(same page). Is it possible? If yes, please send any pointers.
Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not directly.

But you can use JSP mechanisms to create JavaScript markup that re-creates the data of the array.
 
ritesh padhe
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for the reply.
Can you please share any code sample? It will be very helpful for me.

 
Anuj Batra
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me you cannot do it. The array llist creation is on the server side. So when the array list is processed (the whole code in jsp) it is converted into an html page and sent to the client. on client side you do not have any server side code. So it is not possible. However there are certain ways in which this could be achieved like
 
Albareto McKenzie
Ranch Hand
Posts: 304
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anuj Batra wrote:According to me you cannot do it. The array llist creation is on the server side. So when the array list is processed (the whole code in jsp) it is converted into an html page and sent to the client. on client side you do not have any server side code. So it is not possible. However there are certain ways in which this could be achieved like


You can use directly the variable, no need to put it in a hidden field, just use it in the script code: var arrayString = '${temp}'.split(','); or whatever other code you need.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that using scriptlets in JSP pages is no longer acceptable. Use the JSTL and EL like big boys.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!