Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt with filters

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my servlet




[ October 03, 2008: Message edited by: yuvraj kotegar ]
[ October 03, 2008: Message edited by: yuvraj kotegar ]
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my servlet

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the output i get is



Am the Filter

Hello World!

why not the DOUBT line next???
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the browser source show?
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the browser source also same like above it skips the DOUBT LINE
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.close();


'nuff said.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should i remove out.close() line?
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you didn't open it, why are you closing it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic