728x90
index (client)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!--
server + applet = Servlet
client server DB
----- > Servar container
request요청
http
web.xml
< ------
responce응답 동적방식(GET POST)
-->
<h1>servlet 기본</h1>
<form action="location" method = "get">
<input type = "submit" value = "GET방식">
</form>
<form action="location" method = "post">
<input type = "submit" value = "Post방식">
</form>
</body>
</html>
xml에 sevlet 지정
<?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_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>helloServlet</servlet-name>
<servlet-class>sample01.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloServlet</servlet-name>
<url-pattern>/location</url-pattern>
</servlet-mapping>
</web-app>
HelloServlet
package sample01;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("HelloServlet doGet");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("HelloServlet doPost");
}
}
728x90
'HTML' 카테고리의 다른 글
Servlet 실습 3 (html code를 받아 서버에서 확인후 html 출력) 200,404,500 (0) | 2021.03.10 |
---|---|
Servlet 실습 2 (html client에서 받은 데이터를 servlet 서버로 데이터를 날려준다. ) (0) | 2021.03.10 |
40일차//[Web] Servlet이란(중요) (0) | 2021.03.10 |
Web server (0) | 2021.03.10 |
JSON <자신이 읽은 책 5권을 JSON파일로 제작후 테이블로 시각화 하기> (0) | 2021.03.09 |