Merge branch 'main' of http://222.76.244.114:3000/Kane/servlet-learning
init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.cpic.servlet01;
|
||||
|
||||
import java.io.*;
|
||||
import javax.servlet.http.*;
|
||||
import javax.servlet.annotation.*;
|
||||
|
||||
@WebServlet(name = "helloServlet", value = "/hello-servlet")
|
||||
public class HelloServlet extends HttpServlet
|
||||
{
|
||||
private String message;
|
||||
|
||||
public void init()
|
||||
{
|
||||
message = "Hello World!";
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
6
servlet-01/src/main/webapp/WEB-INF/web.xml
Normal file
6
servlet-01/src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
</web-app>
|
13
servlet-01/src/main/webapp/index.jsp
Normal file
13
servlet-01/src/main/webapp/index.jsp
Normal file
@@ -0,0 +1,13 @@
|
||||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>JSP - Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><%= "Hello World!" %>
|
||||
</h1>
|
||||
<br/>
|
||||
<a href="hello-servlet">Hello Servlet</a>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user