View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2012 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  import java.lang.reflect.Method;
23  import java.util.List;
24  import java.util.ArrayList;
25  import java.util.Arrays;
26  
27  import javax.servlet.ServletConfig;
28  import javax.servlet.ServletException;
29  import javax.servlet.ServletOutputStream;
30  import javax.servlet.http.HttpServlet;
31  import javax.servlet.http.HttpServletRequest;
32  import javax.servlet.http.HttpServletResponse;
33  
34  /**
35   * FragmentServlet
36   * 
37   * A web fragment jar. 
38   */
39  
40  public class FragmentServlet extends HttpServlet 
41  {
42      private ServletConfig config;
43      
44      
45      public void init(ServletConfig config) throws ServletException
46      {
47          super.init(config);
48          this.config = config;
49      }
50  
51      
52      
53      /* ------------------------------------------------------------ */
54      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
55      {
56          doGet(request, response);
57      }
58  
59      /* ------------------------------------------------------------ */
60      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
61      {      
62          try
63          {
64              response.setContentType("text/html");
65              ServletOutputStream out = response.getOutputStream();
66              out.println("<html>");
67              out.println("<h1>Jetty Fragment Servlet</h1>");
68              out.println("<body>");
69              out.println("</body>");            
70              out.println("</html>");
71              out.flush();
72          }
73          catch (Exception e)
74          {
75              throw new ServletException(e);
76          }
77      }
78      
79  
80    
81     
82  }