Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setContentType()

 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
If we do response.setContentType with 2 diffenret values in the same servlet, will it give exception? I remember that i read somewhere, if we do so, it will give exception, but i am not getting any exception when i try to do it in TomCat.
Thanks,
Sri.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it shouldn't and it will pick the last contentType set using setContentType before calling output stream, but after you get the output stream content type will not be set even if you call setContentType. This is my point of view
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API:
This method may be called repeatedly to change content type and character encoding.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Satou is always right! You can set multiple contents and the latest one is picked out!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic