• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass values of array to jsp page.

 
Rupa Katkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am having one java class, in that i am having some arrays & i want to pass these array
elements to jsp page for displaying purpose. How should i do this.

My project's flow is like this--> jsp page..servlet..java class(here i am having array).. now i want jsp page for displaying contents of array.
 
Bennet Xavier
Ranch Hand
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

String arr[ ];
request.setParameter("InvalidMeetingDates", arr);

do this in servlet and get the attribute in jsp for iterating by

String[] str = (String[])request.getAttribute("InvalidMeetingDates");

thanks and regards,
Bennet
 
Rupa Katkar
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bennet Xavier wrote:Hi ,

String arr[ ];
request.setParameter("InvalidMeetingDates", arr);

do this in servlet and get the attribute in jsp for iterating by

String[] str = (String[])request.getAttribute("InvalidMeetingDates");

thanks and regards,
Bennet



Hi,
Thanks for your reply,
Mean now i can pass the array elements from servlet to jsp,
but actually i am using java class, in it i am having array.
Now again the question will arise that how i will pass this array from java class to servlet.
If this problem will be solved then my whole problem will get solved.
Please reply.
Thank you once again...
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rupa Katkar wrote:Now again the question will arise that how i will pass this array from java class to servlet.

Servlet is like any other Java class. So how can you return an array of instance or local variable from a method ? Isn't that a basic question of general programming ?
 
Bennet Xavier
Ranch Hand
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after populating the values to the array, return the array from the method you use in java class.

as simple as that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bennet Xavier wrote:request.setParameter("InvalidMeetingDates", arr);

There is no such methiod.

do this in servlet and get the attribute in jsp for iterating by
String[] str = (String[])request.getAttribute("InvalidMeetingDates");

That assumes the use of scriptlets which should not longer be sued in JSPs.

Use the JSTL and El instead.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, to set a scoped variable into the request for use on the JSP use request.setAttribute();
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic