• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Passing array from servlet to JSP  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet, in which i have an array i want to pass the array value to jsp with out any form action.
 
Saloon Keeper
Posts: 4702
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would use the setAttribute method before forwarding the request to the JSP.
 
caba jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting only null value in the jsp
 
Rancher
Posts: 3601
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might need to show the code for both the set in the servlet and how you are accessing the array in the JSP.
 
caba jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please post some sample code
i have iarray[i] this contains some values,i am trying to set in session
like
session.setAttribute("iarray[i]",iarray[i]);
and get it in jsp like session.getAttribute("iarray[i]");
but getting only null
 
Dave Tolls
Rancher
Posts: 3601
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Normally you would set it on the request, unless you needed to maintain it between requests.

Also, that's storing an element in an array, not the array.
Finally that's an odd choice of name.
Why not:


then you can get that on the JSP via JSTL or el...you shouldn't have any Java on the JSP page.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!