• 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 ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

problem with validation  RSS feed

Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose I have Action A that does request.setAttribute(..) before forward the view to a.jsp. in a.jsp there's a button that calls Action B, if B encounters and an error naturally the view gets set to a.jsp. Now there's a problem because a.jsp no longer has access to the attribute that was stored in the original request because it's a new request(?)
I have to redo Action A's logic such as request.setAttribute(..) in action B in case there's an error.. Is there a better way?
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three ways to go on this:

A. Store the object in session scope, rather than the request. This is easy to implement, but can cause performance problems in the long run if the object contains a lot of data and you are expecting a lot of concurrent users. If the object is small, though, this is really the best way to go.

B. Use Hidden fields to store the information. That way, it will get passed on with each form submission. Beware, though, of the possiblity of "spoofing" when using this technique. This means, the user could alter the information in the hidden fields and re-submit the form.

C. Just bite the bullet and get the information from the database again. Most RDBs use caching anyway, so this may not be as expensive as you might think. If speed is really critical, consider implementing your own caching mechanism.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!