41 Advanced java Servlet Tutorial | Understanding OOPS Related to response setContentType text html

Pubblicato il: 05 febbraio 2018
sul canale di: Programming
1,008
127

Advanced java Servlet Tutorial | #Understanding OOPS Related to respo.setContentType("text/html");?
'respo' is response object, nothing but the object of underlaying container supplied java class that impelements javax.servlet.ServletReponse interface directly or indirectly.

setContentType(-) method is declared in javax.servlet.ServletResponse interface like
public void setContentType(String contentType);

in the definition of setContentType(-) logic is available to give instruction to browser window regarding response content type through server.

This method definition is availbale in conatiner supplied java class that implements javax.servlet.ServletResponse interface.

Note: In Tomcat implementation class name of ServletResponse is (availble in catelina.jar):org.apache.catalina.connector.ResponseFacade

In Tomcat implementation class name of ServletRequest is (availble in catelina.jar):org.apache.catalina.connector.RequestFacade

Pointing to response object we can have one of the following two types of streams :

1) PrintWriter Stream
2) ServletOutputStrem

1) PrintWriter Stream: It is a character stream.

Useful to write webpages that contains more text data(char data) & less image page (byte data)

PrintWriter pw=response.getWriter();
pw.println("Hello world");

2) ServletOutputStream: It is a byte stream.
Useful to write web pages that contains more images(byte data )and less text data (char data)

ServletOutputStream sos=response.getOutputStream();
sos.println("Hello World");

Note : We can not use both streams at a time in servlet program.


In questa pagina del sito puoi guardare il video online 41 Advanced java Servlet Tutorial | Understanding OOPS Related to response setContentType text html della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Programming 05 febbraio 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,008 volte e gli è piaciuto 127 spettatori. Buona visione!