This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

the lifespan of a request?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
I have the following actions


I call listDocuments.do and the resulting jsp-page lists some "channels" where it is possible to delete a chosen channel, by following a link to http://localhost:8080/saveChannel.do?method=delete&id=40278. ChannelAction extends DispatchAction. Now, in ChannelAction, I do a check if the channel can be deleted. If not, I do the following:



The thing is now, that listChannels.do does not seem to be able to display the errors. The attribute is gone from the request. Why is this? I have only done one request, as far as I can see. Does Struts consider going to another Action to be a completely new request?

any help would be appreciated!

cheers,
pj
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request is valid only for request time. If you want have data longer use another scope - session for example. I'm not sure how struts handle with request, but it is possible that after forward it creates new request.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request attributes last for the scope of a request.
Forward/include happens on the same request.
A redirect sends a response telling the browser to send a new request.

So request attributes are retained over a forward/include
Request attributes are lost if you issue a redirect.

Looking at your actionforward for /listChannels:
<forward name="forward" redirect="true" path="/channellist.jsp"/>

Solutions
- put the attribute in session
- don't redirect on a "listChannels" request
 
Seriously? That's what you're going with? I prefer this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic