aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Filter question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Filter question" Watch "Filter question" New topic
Author

Filter question

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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,


cmbhatt
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Chandra,

b is correct;
b Apply a filter to the servlet and pass a HttpServletResponseWrapper instead of the original HttpServletResponse to the servlet.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Yeah that is the right choice.


Thanks,
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Jul 23, 2006
Posts: 72
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?


SCJP 1.4: 91%<br />SCWCD 1.4: 85%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

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 ]

rgrds,
Khushhal
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Filter question