Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 312
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Except that using scriptlets in JSP pages is no longer acceptable. Use the JSTL and EL like big boys.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic