This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Custom Error Page Filter  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all-

I'm trying to write a servlet filter that displays custom error pages. (Yes, I do know the standard way of specifying error pages in web.xml but the template of the error page needs to vary and I'd rather not put that logic in a jsp.) I'm doing all the normal wrapping of the response, etc. in order to be able to modify the response, but no matter what I do it just seams to ignore anything written to the output stream. I seem to remember someone telling me once that you cannot modify the response when the status is an error. Is this the case or am I doing something else wrong?
[ August 14, 2008: Message edited by: Michael J. Makunas ]
 
Author and ninkuma
Marshal
Posts: 66801
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't get the filter. Why not just declare a controller servlet as the error handler in the deployment descriptor and handle any decision making there?
 
Michael J. Makunas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
I still don't get the filter. Why not just declare a controller servlet as the error handler in the deployment descriptor and handle any decision making there?



Good point. I thought of something like that after I just posted this. But my concern is that I need/want:

1. To know what the originally requested URL was.
2. To know what the original status code was.
3. To minimize what I have to add to web.xml. In other words can I do something like:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66801
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except for the wild-carding. I usually handle the most common 500, 404, and 403 error codes.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!