Generating an HTML Page in JSP using out.println() method

in #cardano7 years ago (edited)

Generating an HTML Page in JSP using out.println() method

import java.io.;
import java.util.
;
import javax.servlet.;
import javax.servlet.http.
;

/** Simple Hello World Servlet
*/
public class HelloServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter( );
response.setContentType("text/html");
out.println("

Hello from a Servlet");
out.println("

This servlet ran at ");
out.println(new Date().toString( ));
out.println("

Courtesy of HelloServlet.java 1.2 ");
}
}

source: http://www.onjava.com/pub/a/onjava/excerpt/java_cookbook_ch18/index.html?page=2

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 75924.44
ETH 2901.21
USDT 1.00
SBD 2.67