I am new to Servlets.
Please, tell me about this line, and its use in the Jersey Framework + RESTful web services.
PrintWriter out = response.getWriter();
getWriter(); returns the object of PrintWriter Class, in which print(String args) method is declared to print any thing on the browser's page as a response.
getWriter. Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding returned by getCharacterEncoding() .
Class PrintWriter. Prints formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream . It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.
In servlets the output can be either character or byte. for character data (i.e text) u can use PrintWriter for others use ServletOutputStream
PrintWriter: prints text data to a character stream.
getWriter :Returns a PrintWriter object that can send character text to the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With