Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
    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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

how to keep data from one request to another?

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,
i got several DTOs from a Servlet through the request object.

Then, i display data from those DTOs on the page, specifically on a link

And, as you see, i link one field of the DTO to another JSP, and inside this other JSP i still want to get data from the DTOs present in that (the current page) page. In other words, i wanna to keep the DTOs from this request and send to another.
I could set the request attributes again or set HttpSession data, but if i don't wanna do that, is ther a more efficient way???
Thanks,
ltcmelo
 
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
There is no way to cause a request attribute to survive across a request/response boundary.
If this data truly must survive the transition, what's your beef with the session?
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
No beef,
is just thought about a more automated way.
So, if i want to keep the data from this JSP (that initially came from my ServletAction - i'm using struts) to a forwarded JSP, i have to put data on HttpSession. It's the only way, right!?
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Originally posted by Leandro Melo:
No beef,
is just thought about a more automated way.
So, if i want to keep the data from this JSP (that initially came from my ServletAction - i'm using struts) to a forwarded JSP, i have to put data on HttpSession. It's the only way, right!?


Requests attributes and parameters survive request dispatching only.
Struts dispatches requests by default. So, you can access the attributes and parameters in the later jsp.
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I made another "reply" (actually, with a couple more doubts) to this topic on Struts and Other Frameworks forum.
If you could take a look there....
https://coderanch.com/forums/f-58/Struts
 
Bear Bibeault
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

So, you can access the attributes and parameters in the later jsp.


That is not the situation described. The request attributes set during the creation of one JSP will go out of scope when that page is delivered to the client. They will not be available in the page displayed as a result of clicking the link on that first page.
Since this is also being discussed in the Struts forum, this topic will be closed.
 
    Bookmark Topic Watch Topic
  • New Topic