Last active
August 5, 2020 03:56
-
-
Save albert-hg/33ac2e4f229a7a92629236b5093b4056 to your computer and use it in GitHub Desktop.
show the basic java servlet structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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