aspose file tools*
The moose likes JSP and the fly likes Array from one JSP to other (HOW)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Array from one JSP to other (HOW)?" Watch "Array from one JSP to other (HOW)?" New topic
Author

Array from one JSP to other (HOW)?

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Hello,

I have a JSP file that retrive items from an XML and present them in Table. I implement two submit buttons that according the button, JSP goes to other JSP page and sort them. My question is how i can now, to bring back the sorted elements to first JSP and present them on Table. (Sorted items on 2nd JSP stored in Array).
thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

In the controller for the first JSP, cache the data in the session. That way it will be available to the second JSP and its controller.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

You mean to cache session on 2nd JSP so i can access them on JSP?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Yes, caching in the session is one of the most common ways to extend the scope of data across multiple requests.
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

ok i did


Now how i will print out the elements in 1st JSP Table?
I know that i will use but how exactly to get all array's elements?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The JSTL c:forEach tag is the most straightforward way to do that.
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

How i will convert the Object to double?
Can i have a generall structure please about how to get the elements and how to print them out?
thabk you
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You don't convert the Object to double. You let JSTL take care of all of that.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Array from one JSP to other (HOW)?