Skip to content

Instantly share code, notes, and snippets.

@albert-hg
Last active August 5, 2020 03:56
Show Gist options
  • Save albert-hg/33ac2e4f229a7a92629236b5093b4056 to your computer and use it in GitHub Desktop.
Save albert-hg/33ac2e4f229a7a92629236b5093b4056 to your computer and use it in GitHub Desktop.
show the basic java servlet structure
import javax.servlet.*;
import javax.servlet.http.*;
public class HomePage extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println(" <head></head>");
out.println(" <body>");
out.println(" <div> This is home page. <div>");
out.println(" <div> Login:" + request.getSession() + " <div>");
out.println(" </body>");
out.println("</html>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment