Server Tomcat v8.5 Server at localhost failed to start.
해결방법
Tomcat Server → Server Options → Publish module contexts to separate XML files Check
출처
https://beagle-dev.tistory.com/76
+ 강의 교재
Tomcat Server → Server Options → Publish module contexts to separate XML files Check
https://beagle-dev.tistory.com/76
+ 강의 교재
Servlet File 실행하자 다음과 같은 에러 발생
Several ports (8005, 8080) required by Tomcat v8.5 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
default로는 8005, 8080 port로 에러가 뜰 것임.
1. CMD창 실행
2. netstat -naop tcp 입력
3. taskkill /f /pid xxxxx
4. Tomcat 재실행
https://kongpowder.tistory.com/77
[JSP] Could not publish server configuration for Tomcat v8.5 Server at localhost. (0) | 2022.02.24 |
---|---|
[JSP] Server Tomcat v8.5 Server at localhost failed to start. (0) | 2022.02.18 |
[JSP] TEST 실습 (0) | 2022.02.11 |
[JSP] 로그인 실습 (0) | 2022.02.11 |
[JSP] 공부 사이트 정리 (0) | 2022.02.11 |
신종 바이러스인 웜 바이러스는 네트워크를 통해 전파된다. 한 컴퓨터가 웜 바이러스에 걸리면 그 컴퓨터와 네트워크 상에서 연결되어 있는 모든 컴퓨터는 웜 바이러스에 걸리게 된다.
예를 들어 7대의 컴퓨터가 <그림 1>과 같이 네트워크 상에서 연결되어 있다고 하자. 1번 컴퓨터가 웜 바이러스에 걸리면 웜 바이러스는 2번과 5번 컴퓨터를 거쳐 3번과 6번 컴퓨터까지 전파되어 2, 3, 5, 6 네 대의 컴퓨터는 웜 바이러스에 걸리게 된다. 하지만 4번과 7번 컴퓨터는 1번 컴퓨터와 네트워크상에서 연결되어 있지 않기 때문에 영향을 받지 않는다.
어느 날 1번 컴퓨터가 웜 바이러스에 걸렸다. 컴퓨터의 수와 네트워크 상에서 서로 연결되어 있는 정보가 주어질 때, 1번 컴퓨터를 통해 웜 바이러스에 걸리게 되는 컴퓨터의 수를 출력하는 프로그램을 작성하시오.
첫째 줄에는 컴퓨터의 수가 주어진다. 컴퓨터의 수는 100 이하이고 각 컴퓨터에는 1번 부터 차례대로 번호가 매겨진다. 둘째 줄에는 네트워크 상에서 직접 연결되어 있는 컴퓨터 쌍의 수가 주어진다. 이어서 그 수만큼 한 줄에 한 쌍씩 네트워크 상에서 직접 연결되어 있는 컴퓨터의 번호 쌍이 주어진다.
1번 컴퓨터가 웜 바이러스에 걸렸을 때, 1번 컴퓨터를 통해 웜 바이러스에 걸리게 되는 컴퓨터의 수를 첫째 줄에 출력한다.
# 정점의 연결정보 입력받기
n= int(input()) # 정점 // 컴퓨터의 수
m = int(input()) # 연결수 // 연결된 컴퓨터 쌍의 수
graph = [[] for _ in range(n+1)] # 연결된 컴퓨터 쌍의 수 만큼 반복
for _ in range(m):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
visited_dfs = []
def dfs(graph, cur_node, visited):
# 현재 노드를 방문처리
visited.append(cur_node)
graph[cur_node].sort()
# 현재 노드와 인접한 노드를 확인
for link_node in graph[cur_node]:
# 방문하지 않은 노드라면 재귀호출
if link_node not in visited:
dfs(graph, link_node, visited)
dfs(graph, 1, visited_dfs)
print(len(visited_dfs)-1)
* DFS 참고 링크 1 : https://jiwon-coding.tistory.com/93
* DFS 참고 링크 2 : https://devmath.tistory.com/21
from collections import deque
n=int(input())
m=int(input())
computers=[[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
a,b=map(int,input().split())
computers[a][b]=1
computers[b][a]=1
visited=[0]*(n+1)
q=deque()
q.append(1)
visited[1]=1
cnt=0
while q:
now=q.popleft()
for i in range(1,n+1):
if computers[now][i]==1 and visited[i]==0: #연결되어있고 방문한적없으면
visited[i]=1
q.append(i)
cnt+=1
print(cnt)
#include <stdio.h>
#include <stdlib.h>
int map[101][101] = {0};
int visit[101] = {0};
int computer_num, ans = 0;
void dfs(int n){
ans++;
visit[n] = 1;
for (int i=1; i<=computer_num; i++){
if (map[n][i] && !visit[i])
dfs(i);
}
}
int main(){
int n;
int x, y;
scanf("%d %d", &computer_num, &n);
for (int i=0; i<n; i++){
scanf("%d %d", &x, &y);
map[x][y] = map[y][x] = 1;
}
dfs(1);
printf("%d\n", ans - 1);
}
* DFS 참고 링크 : https://code-kh-studio.tistory.com/30
#include <iostream>
#include <queue>
using namespace std;
int V, E;
const int MAX = 101;
int map[MAX][MAX] = { 0, };
bool visited[MAX] = { 0, };
int ans = 0;
queue<int> q;
void BFS(int v) {
visited[v] = true;
//cout << v << " ";
q.push(v);
while (!q.empty()) {
v = q.front();
q.pop();
for (int i = 1; i <= V; i++) {
if (visited[i] == 0 && map[v][i] == 1) {
q.push(i);
visited[i] = true;
ans++;
//cout << i << " ";
}
}
}
}
int main() {
cin >> V >> E;
for (int i = 0; i < E; i++) {
int a, b;
cin >> a >> b;
map[a][b] = 1;
map[b][a] = 1;
}
BFS(1);
cout << ans;
}
* BFS 참고 링크 : https://scarlettb.tistory.com/78
[백준 알고리즘] 10872번 팩토리얼 파이썬 (0) | 2022.02.25 |
---|---|
[백준 알고리즘] 15829번 Hashing (0) | 2022.02.18 |
[백준 알고리즘] 1260번 DFS와 BFS (0) | 2022.02.14 |
[백준 알고리즘] 2745번 진법 변환 (0) | 2022.02.08 |
[백준 알고리즘] 5692번 팩토리얼 진법 (0) | 2022.02.08 |
그래프를 DFS로 탐색한 결과와 BFS로 탐색한 결과를 출력하는 프로그램을 작성하시오. 단, 방문할 수 있는 정점이 여러 개인 경우에는 정점 번호가 작은 것을 먼저 방문하고, 더 이상 방문할 수 있는 점이 없는 경우 종료한다. 정점 번호는 1번부터 N번까지이다.
첫째 줄에 정점의 개수 N(1 ≤ N ≤ 1,000), 간선의 개수 M(1 ≤ M ≤ 10,000), 탐색을 시작할 정점의 번호 V가 주어진다. 다음 M개의 줄에는 간선이 연결하는 두 정점의 번호가 주어진다. 어떤 두 정점 사이에 여러 개의 간선이 있을 수 있다. 입력으로 주어지는 간선은 양방향이다.
첫째 줄에 DFS를 수행한 결과를, 그 다음 줄에는 BFS를 수행한 결과를 출력한다. V부터 방문된 점을 순서대로 출력하면 된다.
n,m,v = map(int,input().split())
graph = [[] * n for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
graph[a].append(b)
graph[b].append(a)
visited = [0] * (n+1)
def dfs(v):
print(v,end=' ')
global visited, graph
visited[v] = 1
for i in sorted(graph[v]):
if visited[i]!=1:
dfs(i)
dfs(v)
print()
from collections import deque
visited = [0] * (n+1)
def bfs(start):
global visited, graph
queue = deque([start])
visited[start] = 1
while queue:
v = queue.popleft()
print(v,end=' ')
for i in sorted(graph[v]):
if visited[i]!=1:
queue.append(i)
visited[i] = 1
bfs(v)
* 참고 링크 : https://jiwon-coding.tistory.com/91
#include <iostream>
#include <queue>
using namespace std;
#define MAX 1001
int N, M, V; //정점개수, 간선개수, 시작정점
int map[MAX][MAX]; //인접 행렬 그래프
bool visited[MAX]; //정점 방문 여부
queue<int> q;
void reset() {
for (int i = 1; i <= N; i++) {
visited[i] = 0;
}
}
void DFS(int v) {
visited[v] = true;
cout << v << " ";
for (int i = 1; i <= N; i++) {
if (map[v][i] == 1 && visited[i] == 0) { //현재 정점과 연결되어있고 방문되지 않았으면
DFS(i);
}
}
}
void BFS(int v) {
q.push(v);
visited[v] = true;
cout << v << " ";
while (!q.empty()) {
v = q.front();
q.pop();
for (int w = 1; w <= N; w++) {
if (map[v][w] == 1 && visited[w] == 0) { //현재 정점과 연결되어있고 방문되지 않았으면
q.push(w);
visited[w] = true;
cout << w << " ";
}
}
}
}
int main() {
cin >> N >> M >> V;
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
map[a][b] = 1;
map[b][a] = 1;
}
reset();
DFS(V);
cout << '\n';
reset();
BFS(V);
return 0;
}
* 참고 링크 : https://scarlettb.tistory.com/76
[백준 알고리즘] 15829번 Hashing (0) | 2022.02.18 |
---|---|
[백준 알고리즘] 2606번 바이러스 (0) | 2022.02.14 |
[백준 알고리즘] 2745번 진법 변환 (0) | 2022.02.08 |
[백준 알고리즘] 5692번 팩토리얼 진법 (0) | 2022.02.08 |
[백준 알고리즘] 10816번 숫자 카드 2 (0) | 2022.01.25 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello World
</body>
</html>
<%@page import="java.util.Date"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
// java.util.Date Class
Date d = new Date();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>jsp 실습</h1>
<%
ArrayList<String> list = new ArrayList<String>();
list.add("A1");
list.add("A2");
list.add("A3");
list.add("A4");
%>
<%= d.toString() %><br>
<%= list %><br>
<h2>ul로 출력</h2>
<ul>
<%
for(String s: list){
%>
<li><%= s %></li>
<%
} // end for
%>
</ul>
<%-- <h3>에러발생</h3>
<%
String name = null;
System.out.println(name.length());
%> --%>
</body>
</html>
강의 실습 + 강의 교재
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String userid = request.getParameter("userid");
String passwd = request.getParameter("passwd");
System.out.println("Tomcat Console 출력:" + userid + "\t" + passwd);
out.print("Browser에 출력:Hello" + userid + "\n");
// Session => HttpSession
session.setAttribute("id", userid);
// Context ==> ServletContext
application.setAttribute("id", userid);
// Init Parameter ==> ServletConfig
String init_param = config.getInitParameter("driver");
%>
아이디:<%= userid %><br>
비번:<%= passwd %><br>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>로그인폼 화면</h1>
<form action="login.jsp" method="get">
아이디:<input type="text" name="userid"><br>
비번:<input type="text" name="passwd"><br>
<input type="submit" value="로그인">
</form>
</body>
</html>
강의 실습 + 강의 교재
https://m.blog.naver.com/eviltwin/221286003266
[유투브] JSP 무료 강좌모음
JSP 강좌 자바를 서버환경에서 사용하는 스크립트 방식의 언어로 자바프로그래밍을 학습한 뒤 이후 활용...
blog.naver.com
Create table If Not Exists Employee (id int, name varchar(255), salary int, departmentId int)
Create table If Not Exists Department (id int, name varchar(255))
Truncate table Employee
insert into Employee (id, name, salary, departmentId) values ('1', 'Joe', '70000', '1')
insert into Employee (id, name, salary, departmentId) values ('2', 'Jim', '90000', '1')
insert into Employee (id, name, salary, departmentId) values ('3', 'Henry', '80000', '2')
insert into Employee (id, name, salary, departmentId) values ('4', 'Sam', '60000', '2')
insert into Employee (id, name, salary, departmentId) values ('5', 'Max', '90000', '1')
Truncate table Department
insert into Department (id, name) values ('1', 'IT')
insert into Department (id, name) values ('2', 'Sales')
Table: Employee
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| id | int |
| name | varchar |
| salary | int |
| departmentId | int |
+--------------+---------+
id is the primary key column for this table.
departmentId is a foreign key of the ID from the Department table.
Each row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.
Table: Department
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
+-------------+---------+
id is the primary key column for this table.
Each row of this table indicates the ID of a department and its name.
Example 1:
Input:
Employee table:
+----+-------+--------+--------------+
| id | name | salary | departmentId |
+----+-------+--------+--------------+
| 1 | Joe | 70000 | 1 |
| 2 | Jim | 90000 | 1 |
| 3 | Henry | 80000 | 2 |
| 4 | Sam | 60000 | 2 |
| 5 | Max | 90000 | 1 |
+----+-------+--------+--------------+
Department table:
+----+-------+
| id | name |
+----+-------+
| 1 | IT |
| 2 | Sales |
+----+-------+
Output:
+------------+----------+--------+
| Department | Employee | Salary |
+------------+----------+--------+
| IT | Jim | 90000 |
| Sales | Henry | 80000 |
| IT | Max | 90000 |
+------------+----------+--------+
Explanation: Max and Jim both have the highest salary in the IT department and Henry has the highest salary in the Sales department.
select
D.Name as Department, E.Name as Employee, Salary
from Employee E inner join Department D
on E.DepartmentID = D.ID
where Salary = (select max(Salary)
from Employee
where E.DepartmentID = DepartmentID);
[Leet Code SQL] 595. Big Countries (0) | 2022.03.04 |
---|---|
[Leet Code] 217. Contains Duplicate python (0) | 2022.02.25 |
[Leet Code] 762. Prime Number of Set Bits in Binary Representation (0) | 2022.02.11 |
[Leet Code] 342_Power of Four (0) | 2022.02.11 |
[Leet Code] 622. Design Circular Queue (0) | 2022.01.21 |
Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.
Recall that the number of set bits an integer has is the number of 1's present when written in binary.
왼쪽과 오른쪽 두 개의 정수가 주어지면 이진 표현에 소수의 세트 비트를 갖는 포함 범위[좌, 우]의 숫자 카운트를 반환합니다.
정수가 갖는 세트 비트의 수는 이진수로 쓸 때 존재하는 1의 수라는 것을 기억하라.
예를 들어, 이진법으로 작성된 21은 10101이고, 3개의 세트 비트를 가지고 있다.
Example 1:
Input: left = 6, right = 10
Output: 4
Explanation:
6 -> 110 (2 set bits, 2 is prime)
7 -> 111 (3 set bits, 3 is prime)
8 -> 1000 (1 set bit, 1 is not prime)
9 -> 1001 (2 set bits, 2 is prime)
10 -> 1010 (2 set bits, 2 is prime)
4 numbers have a prime number of set bits.
Example 2:
Input: left = 10, right = 15
Output: 5
Explanation:
10 -> 1010 (2 set bits, 2 is prime)
11 -> 1011 (3 set bits, 3 is prime)
12 -> 1100 (2 set bits, 2 is prime)
13 -> 1101 (3 set bits, 3 is prime)
14 -> 1110 (3 set bits, 3 is prime)
15 -> 1111 (4 set bits, 4 is not prime)
5 numbers have a prime number of set bits.
Python code
class Solution:
def countPrimeSetBits(self, L: int, R: int) -> int:
return sum(bin(i).count('1') in [2,3,5,7,11,13,17,19] for i in range(L, R+1))
bin(i).count('1') # 이진 표현에서 1의 수가 소수인 경우
bin(i).count('1') in [2, 3, 4, 5, 7, 11, 13, 17, 19]
# 이진 표현에서 1의 수가 [2, 3, 4, 5, 7, 11, 13, 17, 19]에 빈도가 있는 경우
sum(bin(i).count('1') in [2, 3, 5, 7, 11, 13, 17, 19] for i in range(L, R+1))
# sum( ) 함수를 이용하여 count를 증가시킨다.
C ++ code
// c++ code
#include <cmath>
class Solution {
public:
int countPrimeSetBits(int L, int R) {
int res = 0;
for (int num = L; num <= R; num++) {
int count = countOne(num);
if (isPrime(count))
res++;
}
return res;
}
bool isPrime(int num) {
if (num <= 3)
return num > 1;
int square_root = sqrt(num);
for (int i = 2; i <= square_root; i++) {
if (num % i == 0)
return false;
}
return true;
}
int countOne(int num) {
vector<int> bin = dec2bin(num);
int count = 0;
for (auto i = bin.begin(); i < bin.end(); i++) {
if (*i == 1)
count++;
}
return count;
}
vector<int> dec2bin(int num) {
vector<int> bin;
while (num != 0) {
bin.push_back(num % 2);
num /= 2;
}
reverse(bin.begin(), bin.end());
return bin;
}
};
https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/
[Leet Code] 217. Contains Duplicate python (0) | 2022.02.25 |
---|---|
[Leet Code SQL] 184. Department Highest Salary (0) | 2022.02.11 |
[Leet Code] 342_Power of Four (0) | 2022.02.11 |
[Leet Code] 622. Design Circular Queue (0) | 2022.01.21 |
[Leet Code] 232. Implement Queue using Stacks (0) | 2022.01.21 |
Given an integer n, return true if it is a power of four. Otherwise, return false.
An integer n is a power of four, if there exists an integer x such that n == 4x.
Example 1:
Input: n = 16
Output: true
Example 2:
Input: n = 5
Output: false
Example 3:
Input: n = 1
Output: true
Python code
class Solution:
def isPowerOfFour(self, n: int) -> bool:
return math.log(n, 1/4) % 1 == 0 if n > 0 else False
* 참고 링크 : https://leetcode.com/problems/power-of-four/discuss/637372/Python-3-Single-line
C ++ code
class Solution {
public:
bool isPowerOfFour(int num) {
return num > 0 && (num & (num - 1)) == 0 && (num - 1) % 3 == 0;
}
};
[Leet Code SQL] 184. Department Highest Salary (0) | 2022.02.11 |
---|---|
[Leet Code] 762. Prime Number of Set Bits in Binary Representation (0) | 2022.02.11 |
[Leet Code] 622. Design Circular Queue (0) | 2022.01.21 |
[Leet Code] 232. Implement Queue using Stacks (0) | 2022.01.21 |
[Leet Code] 225. Implement Stack using Queues (0) | 2022.01.21 |
+ 강의 교재
[Servlet JSP] Filter API (0) | 2022.02.10 |
---|---|
[Servlet JSP] Web Application에서 DB 연동_MyBatis (0) | 2022.02.09 |
[Servlet JSP] Web Application에서 DB 연동_JDBC (0) | 2022.02.09 |
[Servlet JSP] Scope & Scope Life Cycle (0) | 2022.02.08 |
[Servlet JSP] Servlet 정의 (0) | 2022.02.08 |
+ 강의 교재
[Servlet JSP] Session Tracking (0) | 2022.02.10 |
---|---|
[Servlet JSP] Web Application에서 DB 연동_MyBatis (0) | 2022.02.09 |
[Servlet JSP] Web Application에서 DB 연동_JDBC (0) | 2022.02.09 |
[Servlet JSP] Scope & Scope Life Cycle (0) | 2022.02.08 |
[Servlet JSP] Servlet 정의 (0) | 2022.02.08 |