Created
          January 10, 2014 21:41 
        
      - 
      
 - 
        
Save chrisl8888/8363249 to your computer and use it in GitHub Desktop.  
    Example servlet from http://pdf.coreservlets.com/Servlet-Basics.pdf
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | package coreservlets; | |
| import java.io.*; | |
| import javax.servlet.*; | |
| import javax.servlet.http.*; | |
| /** Simple servlet for testing the use of packages. */ | |
| public class HelloServlet2 extends HttpServlet { | |
| public void doGet(HttpServletRequest request, | |
| HttpServletResponse response) | |
| throws ServletException, IOException { | |
| response.setContentType("text/html"); | |
| PrintWriter out = response.getWriter(); | |
| String docType = | |
| "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " + | |
| "Transitional//EN\">\n"; | |
| out.println(docType + | |
| "<HTML>\n" + | |
| "<HEAD><TITLE>Hello (2)</TITLE></HEAD>\n" + | |
| "<BODY BGCOLOR=\"#FDF5E6\">\n" + | |
| "<H1>Hello (2)</H1>\n" + | |
| "</BODY></HTML>"); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment