• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Why would you extend HttpServletRequestWrapper

 
Greenhorn
Posts: 8
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm reading through the source code of JForum.

I'm going through net.jforum.context.web.WebRequestContext.

The class extends HttpServletRequestWrapper.

My questions are,

1) What would be the purpose of extending HttpServletRequestWrapper ?

2) Why would you need HttpServletRequestWrapper in the first place ?

and last, Why would you need object request parameters where you can just use request attributes ?

 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

That's a good question. From the javadocs: Provides a convenient implementation of the HttpServletRequest interface that can be subclassed by developers wishing to adapt the request to a Servlet.. If there are things you find yourself frequently doing in a web app with respect to the methods of (Http)ServletRequest, you can instead extend HttpServletRequestWrapper to put those functionalities in a single place and be assured they will have been done by the time you get a HttpServletRequest in your servlet.

Looking at that particular example, the two main areas seem some support for multi-part requests (i.e., file uploads, which HttpServletRequest makes awkward to use without the help of a library like Apache Commons FileUpload) and support for MODULE and ACTION parameters (which is part of JForum's way of routing incoming requests to Java code for handling them; that ties in with the modulesMapping.properties and urlPattern.properties files). There are also some other useful extensions, e.g. the getRemoteAddr method knows about the "x-forwarded-for" header convention - something the standard implementation doesn't.
 
Adam Hun
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ulf Dittmer. Now I understand this better
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic