Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forums:
JSP
Servlets
Passing array from servlet to JSP
caba jones
Greenhorn
Posts: 4
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have a
servlet
, in which i have an array i want to pass the array value to
jsp
with out any form action.
Tim Moores
Saloon Keeper
Posts: 7582
176
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You would use the setAttribute method before forwarding the request to the JSP.
caba jones
Greenhorn
Posts: 4
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am getting only null value in the jsp
Dave Tolls
Rancher
Posts: 4801
50
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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: 4801
50
posted 6 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
session.setAttribute("iarray[i]",iarray[i]);
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:
request.setAttribute("Some meaningful name",iarray);
then you can get that on the JSP via JSTL or el...you shouldn't have any
Java
on the JSP page.
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Retrieving values
Passing array from bean to JSP
Pass Javscript array from jsp to servlet
Passing ActionForm attibute to another action Class
Form Submission and reading parameter
More...