Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Jc Hong
Added: Jan 8, 2021 6:02 AM
Views: 5
Tags: no tags
  1. String html = "<!DOCTYPE html>\n"
  2.         + "<html>\n"
  3.         + "<head>\n"
  4.         + "    <title>Hello!</title>\n"
  5.         + "</head>\n"
  6.         + "<body>\n"
  7.         + "<h1>PotaLab Inc.</h1>\n"
  8.         + "<h2>Hello WAFULL World!!!(The Http protocol uses "
  9.         + "com.potalab.wafull.sattang.server.HttpServer)</h2>\n"
  10.         + "</h2>"
  11.         + "</body>\n"
  12.         + "</html>\n";
  13.  
  14.     try {
  15.  
  16.       response.addHeader("Content-Type", "text/html");
  17.       response.addHeader("Content-Length", Integer.toString(html.getBytes().length));
  18.       OutputStream output = response.getOutputStream();
  19.  
  20.       if (output != null) {
  21.         output.write(html.getBytes());
  22.         output.flush();
  23.       }
  24.  
  25.     } catch (Exception e) {
  26.       e.printStackTrace();
  27.     }