Which method is used to specify before any lines that uses the PintWriter?

Options
- setPageType()
- setContextType()
- setContentType()
- setResponseType()


CORRECT ANSWER : setContentType()

Discussion Board
setContentType()

setContentType()- provides the definition of an object to assist a servlet in sending a response to the client. The container of the servlet creates a ServletResponse object and passes it as an argument to the servlet's service method. ServletOutputStream is used to send the binary data in a MIME body response and it is returned by getOutputStream(). PrintWriter is used to send the character data and it is being returned by getWriter() method.
The character set for the MIME body response can be specified explicitly using the setCharacterEncoding(java.lang.String) and setContentType(java.lang.String) methods, or implicitly using the setLocale(java.util.Locale) method. Explicit specifications have higher prcedence over implicity specifications.

Rohit Sharma 11-27-2014 03:53 PM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement