• 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

Filter question

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

--------------------------------------------------------------------------------



You have developed a servlet that extracts customer checking account transaction history and sends it to the browser as a text file. A few months later, you have been asked to ensure that the customer data is sent in encrypted format. How will you do it without changing the servlet code?


Select 1 correct option.
a Apply a filter to the servlet and encrypt the text on-the-fly while it is being sent to the client.
b Apply a filter to the servlet and pass a HttpServletResponseWrapper instead of the original HttpServletResponse to the servlet.
c Apply a filter to the servlet and pass a HttpServletRequestWrapper instead of the original HttpServletRequest to the servlet.
d This cannot be done without change in the servlet code.




Source: Enthu

Thanks,
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chandra,

b is correct;
b Apply a filter to the servlet and pass a HttpServletResponseWrapper instead of the original HttpServletResponse to the servlet.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah that is the right choice.


Thanks,
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more question arises:

Can a HttpServletRequestWrapper modify the header of a request within
javax.servlet.Filter implementing class?

If yes, won't it leave some dependency?

Thanks,
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chandra Bhatt:
Yeah that is the right choice.


Thanks,



I am still learning. But can someone explain, how will the browser de-crypt the encrypted text-file. I guess the browser will need to use some kind of key, to decrypt the message right?
 
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

I guess the browser will need to use some kind of key, to decrypt the message right?


I think that the file is meant to be saved, not to be displayed in the web browser.
 
Ranch Hand
Posts: 242
Mac Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chandra

Can a HttpServletRequestWrapper modify the header of a request within
javax.servlet.Filter implementing class?



Ofcourse, it's possible, but you can't directly modify the header of the request(as their is no setHeader(String) method), but you can override the getHeader() method in such a way that it will give you what you expected it to return.
Look at the code below


Regards,
Khushhal
[ August 18, 2007: Message edited by: khushhal yadav ]
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic