• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Constructor Signature for class that extends HttpServletRequestWrapper?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello and apologies for this noob question!
I'm going through Charles Lyons OCEJWCD Study Companion...
I've just finished Chapter 6 Revision Questions and 2 questions I don't seem to understand. Q17 & Q18 (p153).
I understand why and the use of Wrappers, just not the syntax of the constructor he calls in the above questions.

In the book for Q17 & Q18 (p153) it has :

I thought the constructor would be :
i.e passing the interface type HttpServletRequest so it can get stored on the ServletRequestWrapper instance variable.
Or is his code correct due to HttpServletRequestWrapper passes the IS-A test and is a HttpServletRequest by virtue of HttpServletRequestWrapper implementing HttpServletRequest which extends ServletRequest.??

Sorry . . . confused.com, or I'm just too fried! :-)

Thank you. :-)

 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know the book so I can only react on your comments here.

I thought the constructor would be :
public class MyRequestWrapper extends HttpServletRequestWrapper {
public MyRequesterWrapper(HttpServletRequest wrap){
super(wrap);
}
//other code here
}


That is what you normally would do with the wrapper class. It could be a mistake in the book....

Or is his code correct due to HttpServletRequestWrapper passes the IS-A test and is a HttpServletRequest by virtue of HttpServletRequestWrapper implementing HttpServletRequest which extends ServletRequest.??


The code is correct (it compiles and probably runs) and you are correct about the reason, however, I am not sure what the author wants to do with wrapping the wrapper. Is he wrapping somebody else's wrapper class in the question setup?
 
reply
    Bookmark Topic Watch Topic
  • New Topic