aspose file tools*
The moose likes Servlets and the fly likes doubt with filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "doubt with filters" Watch "doubt with filters" New topic
Author

doubt with filters

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
this is my servlet




[ October 03, 2008: Message edited by: yuvraj kotegar ]
[ October 03, 2008: Message edited by: yuvraj kotegar ]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
why the line marked as DOUBT LINE is not showing in the response of the the servlet.

By the way the above code is my Filter class
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Perhaps because it's before the <html> tag of the rest of the response, so the browser doesn't display it?
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
this is my servlet

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
the output i get is



Am the Filter

Hello World!

why not the DOUBT line next???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

What does the browser source show?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
the browser source also same like above it skips the DOUBT LINE
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

out.close();


'nuff said.
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
should i remove out.close() line?
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Originally posted by yuvraj kotegar:
should i remove out.close() line?


Yes, as you have already closed the writer associated with reponse, anything written afterwards is not displayed. By the way, it is better not to use filters for writing to the reponse. They are more suitable for implementing filtering logic like authentication etc.


Thanks and Regards
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

If you didn't open it, why are you closing it?
 
Don't get me started about those stupid light bulbs.
 
subject: doubt with filters