Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Best way to retrieve variables from another jsp

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey bear and others,

I have a page that is filled with data some user inputed some hiddens that were passed. When they click a button such as more? or help? I do a sumbit to a new jsp. Once they choose an option from there I need to go back to the previous jsp. Is there anyway to keep all the values other than sumbitting all those to the new jsp and sending them back once I submit again?

Thanks,
Randy
 
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's one way -- and a way I often employ.

Another is to store the data in the session for later retrieval. If you go that route be careful to manage the session data carefully and remove it when no longer needed.

Yet another approach -- for items such as help and hints and other information that isn't really part of the workflow -- is to not replace the main page with the display of the ancillary information at all.

Rather, you could display it another window, in an iframe in the current window, or (a technique I very often use) a floating div that appears above the workflow data. That way, your workflow is never interrupted and moving the data around becomes a moot point.
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can extract the data from the request object and store it in the user's Session object. But that can become tedious for complex forms.

A better solution is to use something like Struts' ActionForm. It makes managing form data much easier. Especially if have a multi-page form or you are doing form validation.

Take a look at Struts in Action by Ted Husted, et al, for more info.
 
Bear Bibeault
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adopting a behemoth like Struts just for this little feature seems a bit overkill to me.
 
Tempora Telora
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with bear here. Granted I didnt state it but I will state it now : I will only be returning one string I do like the strut though I will be using that later on in different web app they want me to build.

Thank you,
Randy
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, if you are talking about saving only one value, then managing that yourself is definitely easier.

I won't argue the point about Struts being a behemoth! Especially if you are new to it. But it and other MVC frameworks do help build more maintainable web apps.

But for a simple app that will never grow beyond a couple of small forms, it's overkill.
 
Bear Bibeault
Marshal
Posts: 67357
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Scott Johnson:
But it and other MVC frameworks do help build more maintainable web apps.



There are those, myself included, who would still disagree on that point. Following accepted practices and using a good web application structure make a web app (or any program for that matter) maintainable and extensible.

Large frameworks are not necessary to achieve that.
[ June 20, 2006: Message edited by: Bear Bibeault ]
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Following accepted practices and using a good web application structure make a web app (or any program for that matter) maintainable and extensible.



I totally agree. No framework is required to build a maintainable and extensible application. But a good framework can help achieve those goals. (And a bad framework can make your life miserable. )
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!