Skip to content

Instantly share code, notes, and snippets.

@bouzuya
Created February 4, 2013 13:15
Show Gist options
  • Select an option

  • Save bouzuya/4706681 to your computer and use it in GitHub Desktop.

Select an option

Save bouzuya/4706681 to your computer and use it in GitHub Desktop.
package com.github.bouzuya;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletExample extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String title = "ServletExample";
String content = "Hello, World!";
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html lang=\"en\">");
out.println(" <head>");
out.println(" <title>" + title + "</title>");
out.println(" </head>");
out.println(" <body>");
out.println(" <p>" + content + "</p>");
out.println(" </body>");
out.println("</html>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment