Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServletRequestWrapper

 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone shed some light as to when a developer would want to use this class? Actually, when would a developer want to use any of the wrapped request/response classes?
 
Sam Cala
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you want to provide your own functionality to any of the methods of HttpServletRequest/HttpServletResponse, you can use the wrapper classes. I mean if you want to set a content type of response, you can yourself give body to setContentType method of HttpServletResponse instead of just calling it.
This is what I suppose :roll: Someone pls. correct me if I'm wrong.
 
Ricardo Cortes
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. Interesting. Why wouldn't a developer just subclass HttpServletRequest/HttpServletResponse instead?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are interfaces, implementing your own wrapper class from scratch is mostly trivial but incredibly tedious -- been there, done that.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic