• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Filters and Design Pattens

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey any body please tell me a place to find about response wrappers and design patterns this is urgent my exam is on next thursday 06th december
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
About Design Patterns, study this document. About filters, you could try to make a filter chain, wrap the response using the ResponseWrapper, and see what it works. I don't think there's anything fancy about it.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Response wrappers (or even request wrappers for that matter) are not on the exam. If there's any mention of them at all, all you'd need to know about them is that you'd create them inside an Intercepting Filter. Pretty much what Christophe said.

If you run into any doubts/questions while studying the Peabody on Patterns document, please post them here and we'll be glad to help you out.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, wrappers are in the objectives and they very well might be on the exam.

Even if you don't get a question on the exam about them, they're definitely worth learning. They're a huge part of what makes Filters so awesome. They're also a great way to get more familiar with the Decorator pattern.

Let's say I want to make my application unable find any Cookies in any request...

I can write a wrapper for the request and pass the wrapper along to the application through the FilterChain. My application will think that it's talking directly to the request object but it will actually be talking to a different object that implements the ServletRequest interface - my wrapper object!

The HttpServletRequestWrapper class I will extend is really cool. It has a default behavior for every method that just spits out whatever the original request object would return for that method. I only have to override the methods I want to behave differently. In this case, I want to override the getKookies* method because I want my application to believe that there aren't any cookies.


There's all kinds of cool things you can do with wrappers. Come up with some ideas of your own and try them out. You can even put a wrapper on the response object. My code should give you a good head start.

Happy wrapping!

* change getKookies to use a 'C' - I had to use a 'K' to get around a limitation set by the JavaRanch forum software
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic