Adding Hello world Servlet and HTML impl

This commit is contained in:
Chirag Dewan 2018-08-08 22:19:00 +05:30
parent 2650a1d5ea
commit 216715010b
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package com.baeldung.jetty;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/helloworld")
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 2851388791344172542L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
writer.println("<!DOCTYPE html>");
writer.println("<html>");
writer.println("<body>");
writer.println("<p>Hello World!</p>");
writer.println("</body>");
writer.println("</html>");
}
}

View File

@ -0,0 +1,10 @@
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<welcome-file-list>
<welcome-file>helloworld.html</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Hello World</title>
</head>
<body>Hello World!
</body>
</html>