| 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; |
| 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 |
* Dump Servlet Request. |
| 27 |
*/ |
| 28 |
@SuppressWarnings("serial") |
| 29 |
public class HelloWorld extends HttpServlet |
| 30 |
{ |
| 31 |
|
| 32 |
@Override |
| 33 |
public void init(ServletConfig config) throws ServletException |
| 34 |
{ |
| 35 |
super.init(config); |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException |
| 40 |
{ |
| 41 |
doGet(request, response); |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException |
| 46 |
{ |
| 47 |
response.setContentType("text/html"); |
| 48 |
ServletOutputStream out = response.getOutputStream(); |
| 49 |
out.println("<html>"); |
| 50 |
out.println("<h1>Hello World</h1>"); |
| 51 |
out.println("</html>"); |
| 52 |
out.flush(); |
| 53 |
} |
| 54 |
} |