This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Returning Previous Response  RSS feed

 
Mark Newton
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm pretty sure that this is a dumb question, but I've been Googling around for a while, and can't think what to search for...

Basically, I'm working on a Struts Interceptor, for handling multiple submits. I'm using the Synchronizer Token design pattern; saving a simple number on the client page, and in the session. Upon the submit I check that the numbers match, and, if so, increment the number in the session. Then I have a custom tag which gets that incremented number when it renders the next JSP page. The predictability of simply incrementing numbers has been considered, and is not a problem for us.

I think (hope) that's all sensible, and is well documented in various places talking about the Synchronizer Token pattern. What I'm stuck on is how to handle the case when the values don't match. I want to store the response that was sent back the first time, and, upon hitting the interceptor with a previous 'token', pull out that response and re-send it, without needing to go any further into my application. My question is simply: where and how do I store that response.

I'm pretty new to Servlets (and JEE in general), but have a few years of core Java, and JSE experience. Can I just keep a map somewhere with key=value of token=response? Is that safe for threads / multiple servers / etc, etc? If not - what's better?!
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I just keep a map somewhere with key=value of token=response? Is that safe for threads / multiple servers / etc, etc? If not - what's better?!


Creating the dynamic response from the servlet itself.
 
Mark Newton
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ashok, but sorry, I don't fully understand your response. Do you mean to just repeat the same functionality that was used for the original request? That's what we're trying to avoid really - if we've already generated the response, we want to just return it from the interceptor, without having to go any further.

Sorry if I mis-understood what you meant!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!