This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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: 18986
    
    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: 61758
    
  67

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: 61758
    
  67

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: 61758
    
  67

If you didn't open it, why are you closing it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt with filters