• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting PrintWriter out = response.getWriter(); out.print("My Servlet"); response.setContentType

 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it problem setting response.setContentType("text/html"); after sending the response to client?

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing will happen. The default value of response.setContentType() is text/html. Even if you don't give response.setContentType("text/html") also it will work.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, the PrintWriter is typically backed by a BufferedWriter, so the response may not have been written at that point.
As long as the response is still buffered it is possible to change data in the header, but not afterwards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!