Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filters and Design Pattens

 
Mihiruwan Amarasinghe
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic