HelloServlet.java 765 Bytes
Newer Older
Jose Baez committed
1 2
package com.roshka.proyectofinal;

3 4 5 6 7
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

Jose Baez committed
8
import java.io.*;
9

Jose Baez committed
10 11 12

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
13
    private String message="HOLA";
Jose Baez committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}