Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HttpServletRequestWrapper

 
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?
 
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?
 
author
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
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic