Created
February 24, 2014 04:14
-
-
Save sochoa/9181877 to your computer and use it in GitHub Desktop.
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 required java libraries | |
import java.io.*; | |
import javax.servlet.*; | |
import javax.servlet.http.*; | |
// Extend HttpServlet class | |
public class HelloWorld extends HttpServlet { | |
private String message; | |
public void init() throws ServletException | |
{ | |
// Do required initialization | |
message = "Hello World"; | |
} | |
public void doGet(HttpServletRequest request, | |
HttpServletResponse response) | |
throws ServletException, IOException | |
{ | |
// Set response content type | |
response.setContentType("text/html"); | |
// Actual logic goes here. | |
PrintWriter out = response.getWriter(); | |
out.println("<h1>" + message + "</h1>"); | |
} | |
public void destroy() | |
{ | |
// do nothing. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment