jsp blog setting
This commit is contained in:
49
jspblog/pom.xml
Normal file
49
jspblog/pom.xml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>jspblog</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>jspblog</name>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<junit.version>5.7.0</junit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>4.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
27
jspblog/src/main/java/com/example/jspblog/HelloServlet.java
Normal file
27
jspblog/src/main/java/com/example/jspblog/HelloServlet.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.jspblog;
|
||||||
|
|
||||||
|
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
jspblog/src/main/webapp/WEB-INF/web.xml
Normal file
6
jspblog/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
jspblog/src/main/webapp/index.jsp
Normal file
13
jspblog/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>
|
||||||
35
jspblog/table
Normal file
35
jspblog/table
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
MySQL 데이터베이스 생성 및 사용자 생성
|
||||||
|
create user 'bloguser'@'%' identified by 'bitc5600';
|
||||||
|
GRANT ALL PRIVILEGES ON *.* TO 'bloguser'@'%';
|
||||||
|
create database blog;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE user(
|
||||||
|
id int primary key auto_increment,
|
||||||
|
username varchar(100) not null unique,
|
||||||
|
password varchar(100) not null,
|
||||||
|
email varchar(100) not null,
|
||||||
|
address varchar(100),
|
||||||
|
userRole varchar(20),
|
||||||
|
createDate timestamp
|
||||||
|
) engine=InnoDB default charset=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE board(
|
||||||
|
id int primary key auto_increment,
|
||||||
|
userId int,
|
||||||
|
title varchar(100) not null,
|
||||||
|
content longtext,
|
||||||
|
readCount int default 0,
|
||||||
|
createDate timestamp,
|
||||||
|
foreign key (userId) references user (id)
|
||||||
|
) engine=InnoDB default charset=utf8;
|
||||||
|
|
||||||
|
CREATE TABLE reply(
|
||||||
|
id int primary key auto_increment,
|
||||||
|
userId int,
|
||||||
|
boardId int,
|
||||||
|
content varchar(300) not null,
|
||||||
|
createDate timestamp,
|
||||||
|
foreign key (userId) references user (id) on delete set null,
|
||||||
|
foreign key (boardId) references board (id) on delete cascade
|
||||||
|
) engine=InnoDB default charset=utf8;
|
||||||
Reference in New Issue
Block a user