View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package com.acme;
20  
21  import java.io.IOException;
22  
23  import javax.servlet.ServletConfig;
24  import javax.servlet.ServletException;
25  import javax.servlet.ServletOutputStream;
26  import javax.servlet.http.HttpServlet;
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  
30  /**
31   * FragmentServlet
32   * 
33   * A web fragment jar. 
34   */
35  
36  public class FragmentServlet extends HttpServlet 
37  {
38      private ServletConfig config;
39      
40      
41      public void init(ServletConfig config) throws ServletException
42      {
43          super.init(config);
44          this.config = config;
45      }
46  
47      
48      
49      /* ------------------------------------------------------------ */
50      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
51      {
52          doGet(request, response);
53      }
54  
55      /* ------------------------------------------------------------ */
56      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
57      {      
58          try
59          {
60              response.setContentType("text/html");
61              ServletOutputStream out = response.getOutputStream();
62              out.println("<html>");
63              out.println("<h1>Jetty Fragment Servlet</h1>");
64              out.println("<body>");
65              out.println("</body>");            
66              out.println("</html>");
67              out.flush();
68          }
69          catch (Exception e)
70          {
71              throw new ServletException(e);
72          }
73      }
74      
75  
76    
77     
78  }