Debian Codegraph @

jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-spec/jetty-ee9-demo-web-fragment/src/main/java/org/example/fragment/FragmentServlet.java

raw
1 //
2 // ========================================================================
3 // Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
4 //
5 // This program and the accompanying materials are made available under the
6 // terms of the Eclipse Public License v. 2.0 which is available at
7 // https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
8 // which is available at https://www.apache.org/licenses/LICENSE-2.0.
9 //
10 // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
11 // ========================================================================
12 //
13
14 package org.example.fragment;
15
16 import java.io.IOException;
17
18 import jakarta.servlet.ServletConfig;
19 import jakarta.servlet.ServletException;
20 import jakarta.servlet.ServletOutputStream;
21 import jakarta.servlet.http.HttpServlet;
22 import jakarta.servlet.http.HttpServletRequest;
23 import jakarta.servlet.http.HttpServletResponse;
24
25 /**
26 * FragmentServlet
27 *
28 * A web fragment jar.
29 */
30
31 public class FragmentServlet extends HttpServlet
32 {
33 private ServletConfig config;
34
35 @Override
36 public void init(ServletConfig config) throws ServletException
37 {
38 super.init(config);
39 this.config = config;
40 }
41
42 @Override
43 public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
44 {
45 doGet(request, response);
46 }
47
48 @Override
49 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
50 {
51 try
52 {
53 response.setContentType("text/html");
54 ServletOutputStream out = response.getOutputStream();
55 out.println("<html>");
56 out.println("<h1>Jetty Fragment Servlet</h1>");
57 out.println("<body>");
58 out.println("</body>");
59 out.println("</html>");
60 out.flush();
61 }
62 catch (Exception e)
63 {
64 throw new ServletException(e);
65 }
66 }
67 }