Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter question

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • 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,
 
Srinivasan thoyyeti
Ranch Hand
Posts: 557
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yeah that is the right choice.


Thanks,
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • 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,
 
Arnab Sinha
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
khushhal yadav
Ranch Hand
Posts: 242
Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic