개발새발 블로그

[JavaSpring] request

컴퓨터/JSP
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>Request Ex1</h1>
	<form action="01.2.request.jsp">
		이름 : <input name="name"><br>
		학번 : <input name="studentNum"><br>
		성별 : 남자<input type="radio" name="gender" value="남">&emsp;
			  여자<input type="radio" name="gender" value="여"><p/>
		전공 : <select name="major">
			<option value="국문학과">국문학과</option>
			<option value="영문학과">영문학과</option>
			<option value="수학과">수학과</option>
			<option value="컴퓨터학과">컴퓨터학과</option>
			<option value="경제학과">경제학과</option>
		</select><p/>
		취미 : <input type="checkbox" name="hobby" value="여행">여행&emsp;
		<input type="checkbox" name="hobby" value="운동">운동&emsp;
		<input type="checkbox" name="hobby" value="공부">공부&emsp;
		<input type="checkbox" name="hobby" value="영화">영화&emsp;
		<input type="checkbox" name="hobby" value="숏폼">숏폼<p/>
		<input type="submit">
	</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String name = request.getParameter("name");
	String sNum = request.getParameter("studentNum");
	String gender = request.getParameter("gender");
	String major = request.getParameter("major");
	String hobby[] = request.getParameterValues("hobby");
%>  

  
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	이름 : <%=name %><p/>
	학번 : <%=sNum %><p/>
	성별 : <%=gender %>자<p/>
	전공 : <%=major %><p/>
	취미 : 
	<%
		for(int i=0; i<hobby.length; i++) {
			out.print(hobby[i] + ", ");
		}
	%>
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] out  (0) 2024.07.16
[JavaSpring] request_infoMethod  (0) 2024.07.16
[JavaSpring] action_forward 혈액형 연습 문제  (13) 2024.07.16
[JavaSpring] action_forward  (2) 2024.07.16
[JavaSpring] action_includeTag  (0) 2024.07.16

[JavaSpring] action_scriptTag

컴퓨터/JavaScript
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>scriptTag</title>
</head>
<body>
	<%-- <%! 선언문 (멤버변수,메서드) %> --%>
	<jsp:declaration>
		public int min(int x, int y) {
			return x > y ? y : x;
		}
	</jsp:declaration>
	
	<%-- <% 스크립트릿 (지역변수,for,if..)%> --%>
	<jsp:scriptlet>
		int num = 1;
	</jsp:scriptlet>
	
	<%-- <%=표현식 (변수나 메서드 호출하여 출력)  %> --%>
	num = <jsp:expression>num</jsp:expression><br>
	3와 5중 작은 수는? <jsp:expression>min(3,5)</jsp:expression>
</body>
</html>

'컴퓨터 > JavaScript' 카테고리의 다른 글

[JavaSpring] response  (0) 2024.07.16
[JavaScript] 정규표현식  (0) 2024.07.09
[JavaScript] 이벤트  (0) 2024.07.08
[JavaScript] window용 객체  (0) 2024.07.08
[JavaScript] 분해 할당  (0) 2024.07.08

[JavaSpring] action_forward 혈액형 연습 문제

컴퓨터/JSP
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Blood Ex</title>
</head>
<body>
	<h1>혈액형으로 보는 성격</h1>
	<form action="09.2.bloodForward.jsp">
		이름 : <input name="name"><br>
		혈액형 :
		<input type="radio" name="bloodType" value="A">A형&emsp;
		<input type="radio" name="bloodType" value="B">B형&emsp;
		<input type="radio" name="bloodType" value="O">O형&emsp;
		<input type="radio" name="bloodType" value="AB">AB형<br>
		<input type="submit">
	</form>
</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>
<%
	request.setCharacterEncoding("utf-8");
	String name = request.getParameter("name");
	String bloodType = request.getParameter("bloodType");
%>
</head>
<body>
	<jsp:forward page='<%=bloodType + ".jsp" %>'/>
</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>
<%
	request.setCharacterEncoding("utf-8");
	String name = request.getParameter("name");
	String bloodType = request.getParameter("bloodType");
%>
</head>
<body>
	<b><%=name %></b>님의 혈액형은 <b><%=bloodType %>형</b>이고, 성격은 다음과 같습니다<br>
	어떤 상황에서든 염려하며 조심성이 강하다.<br>
	감동을 잘하며 자기를 희생해서라도 다투기를 피한다.<br>
	순응적이고 자신의 개성을 누른다.<br>
	성실하며 인내심이 강하고 모험을 하지 않는다.<br>
	은근히 할말 다하며 내숭이 있다.<br>
	잘 삐지고 오래간다.<br>
	쑥스러움이나 낯가림을 느낀다.<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>
<%
	request.setCharacterEncoding("utf-8");
	String name = request.getParameter("name");
	String bloodType = request.getParameter("bloodType");
%>
</head>
<body>
	<b><%=name %></b>님의 혈액형은 <b><%=bloodType %>형</b>이고, 성격은 다음과 같습니다<br>
	몹시 섬세하고 신경질적인 것 같기도 하다<br>
	반대로 쉬어보이면서도 차갑다<br>
	두 가지 성격이 섞여 있어 잘 알기 어렵고 이성교제에 있어 제일 애를 먹는다.<br>
	너무 여러 가지 많은 것에 신경을 쓰며 낯가림을 많이 한다.<br>
	감정표현에 서툴고 아부하거나 나대는 것을 싫어한다.<br>
	비관적이고 의심이 많다.<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>
<%
	request.setCharacterEncoding("utf-8");
	String name = request.getParameter("name");
	String bloodType = request.getParameter("bloodType");
%>
</head>
<body>
	<b><%=name %></b>님의 혈액형은 <b><%=bloodType %>형</b>이고, 성격은 다음과 같습니다<br>
	사람과 교제하는 것을 좋아하고 산뜻하다.<br>
	무엇이든 마음속에 오래 품고 있지 않고 금방 잊어버린다.<br>
	눈치가 빠르고 사교적인 편이다.<br>
	A형과 반대로 개성을 강하게 드러내며 행동적이고 정열적이다.<br>
	연애에 있어 쉽게 달구어지고 쉽게 깨지기 쉽다. <br>
	자신이 맞다고 느끼면 무슨 일이 있어도 밀어붙인다.<br>
	귀가 얇고 직설적이다.<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>
<%
	request.setCharacterEncoding("utf-8");
	String name = request.getParameter("name");
	String bloodType = request.getParameter("bloodType");
%>
</head>
<body>
	<b><%=name %></b>님의 혈액형은 <b><%=bloodType %>형</b>이고, 성격은 다음과 같습니다<br>
	침착하며 감정에 휘둘리지 않는다.<br>
	어떤 상황에서든 가볍게 보지 않는다.<br>
	남의 말에 잘 움직이지 않고 정신력이 강하다. <br>
	점잖고 자부심이 강하다<br>
	변화를 좋아하고 유머가 있다.<br>
	로맨티스트로 여러 분야에서 천재적 소질을 가지고 있다.<br>
	리더 역할을 할 때가 많고 기분파이며 솔직하다.<br>
	호불호가 심하고 표정을 잘 못 숨긴다.<br>
	일단 저지르고 본다.
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] request_infoMethod  (0) 2024.07.16
[JavaSpring] request  (0) 2024.07.16
[JavaSpring] action_forward  (2) 2024.07.16
[JavaSpring] action_includeTag  (0) 2024.07.16
[JavaSpring] page_include  (0) 2024.07.16

[JavaSpring] action_forward

컴퓨터/JSP
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forward1</title>
</head>
<body>
	<h1>Forward</h1>
	<form action="08.2.action_forward2.jsp">
		ID : <input name="id"><p/>
		PW : <input type="password" name="pw"><p/>
		<input type="submit">
	</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forward2</title>
</head>
<body>
	<h1>forword page</h1>
	Forward Tag의 포워딩 되기전의 페이지입니다<p/>
	<jsp:forward page="08.3.action_forword3.jsp" />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forward3</title>
</head>
<body>
	<%
		String id=request.getParameter("id");
		String pw=request.getParameter("pw");
	%>
	당신의 아이디는 <b><%=id %></b>이고,<p/>
	비밀번호는 <b><%=pw %></b>입니다
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] request  (0) 2024.07.16
[JavaSpring] action_forward 혈액형 연습 문제  (13) 2024.07.16
[JavaSpring] action_includeTag  (0) 2024.07.16
[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16

[JavaSpring] action_includeTag

컴퓨터/JSP
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="06.2.action_includeTag2.jsp">
		이름 : <input name="name"><br>
		<input type="submit">
	</form>
</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>
<%
	request.setCharacterEncoding("utf-8");
	String name = "Korea web JSP";
%>
<h1>Action의 Include Tag</h1>
<jsp:include page="06.3.action_includeTag3.jsp" /><p/>
Action의 include Body입니다.
<%=name %>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<%
	String name = request.getParameter("name");
%>
Action의 IncludeTag의 Top입니다<p/>
<%=name %> Fighting!!!
</body>
</html>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="07.2.action_includeTag2.jsp">
		siteName : <input name="siteName"><p/>
		siteTel : <input name="siteTel"><p/>
		<input type="submit">
	</form>
</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>
	<%
		request.setCharacterEncoding("utf-8");
		String siteName = request.getParameter("siteName");
		String siteTel = request.getParameter("siteTel");
	%>
	<h1>Action IncludeTag파라미터 받기</h1>
	<jsp:include page="07.3.action_includeTag3.jsp">
		<jsp:param value="jsp수업중" name="siteName"/>
		<jsp:param value="02-1345-6789" name="siteTel"/>
	</jsp:include>
	<%=siteName %><br>
	<%=siteTel %>
</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>
	<%
		request.setCharacterEncoding("utf-8");
		String siteName = request.getParameter("siteName");
		String siteTel = request.getParameter("siteTel");
	%>
	Action의 includeTag Top입니다<br>
	Top : <%=siteName %><br>
	Top : <%=siteTel %><br>
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] action_forward 혈액형 연습 문제  (13) 2024.07.16
[JavaSpring] action_forward  (2) 2024.07.16
[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16
[JavaSpring] page_info  (0) 2024.07.16

[JavaSpring] page_include

컴퓨터/JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Include Body</title>
</head>
<body>
	<h1>Include Body</h1>
	<%@ include file="05.2.page_include_Top.jsp" %><br>
	include지시자의 Body부분 입니다.<br>
	<%@ include file="05.3.page_include_Bottom.jsp" %>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Top</title>
</head>
<body>
	include지시자의 Top부분입니다.
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bottom</title>
</head>
<body>
	include지시자의 Bottom부분입니다.
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] action_forward  (2) 2024.07.16
[JavaSpring] action_includeTag  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16
[JavaSpring] page_info  (0) 2024.07.16
[JavaSpring] for문, while문  (0) 2024.07.15

[JavaSpring] trimWhitespace, userErrorPage

컴퓨터/JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page session="true"%> 
<%@ page buffer="16kb"%>
<%@ page autoFlush="true" %>
<%@ page trimDirectiveWhitespaces = "true" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>page_etc</title>
</head>
<body>
	<%
		Date date = new Date();
	%>
	<p>현재 날짜와 시간은?</p>
	<%=date.toLocaleString() %>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>userErrorPage</title>
</head>
<body>
	<% int one=1, zero=0; %>
	<h1>ErrorPage</h1>
	<p>one과 zero의 사칙연산</p>
	one+zero=<%=one+zero %><p/>
	one-zero=<%=one-zero %><p/>
	one*zero=<%=one*zero %><p/>
	one/zero=<%=one/zero %><p/>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" %>
<%@ page isErrorPage="true" %>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3>0으로 나눌 수 없습니다</h3>
<%-- 
	<p>다음과 같은 예외가 발생되었습니다</p>
	에러타입 : <%=exception.getClass().getName() %><br>
	에러메시지 : <%=exception.getMessage() %>
	 --%>
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] action_includeTag  (0) 2024.07.16
[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] page_info  (0) 2024.07.16
[JavaSpring] for문, while문  (0) 2024.07.15
[JavaSpring] if문  (0) 2024.07.15

[JavaSpring] page_info

컴퓨터/JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page info="JSP 현재 페이지의 정보" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>page_info</title>
</head>
<body>
	<h1>page_info</h1>
	<%=this.getServletInfo() %>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*, java.io.*" 
		 session="true" 
		 buffer="16kb"
		 autoFlush="true" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>page_etc</title>
</head>
<body>
	<%
		Date date = new Date();
	%>
	<p>현재 날짜와 시간은?</p>
	<%=date.toLocaleString() %>
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16
[JavaSpring] for문, while문  (0) 2024.07.15
[JavaSpring] if문  (0) 2024.07.15
[JavaSpring] Hello JavaSpring  (0) 2024.07.15

[JavaSpring] for문, while문

컴퓨터/JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>for</title>
</head>
<body>
<%-- <%
	int sum = 0;
	for (int i=1; i<=10; i++) {
		if(i < 10)
			out.print(i + " + ");
		else
			out.print(i + " = ");
		
		sum += i;
	}
%> --%>

<%
	int sum = 0;
	for (int i=1; i<=10; i++) {
		if(i < 10) {  // jsp를 끊었다가 쓸때는 반드시 중괄호를 해준다
%>
			<%=(i + " + ") %>
<%
		} else {
%>
			<%=(i + " = ") %>
<%
		}
		sum += i;
	}
%>
<%=sum %><br><br>

<%
	int arr[] = new int[10];
	for(int i=0; i<arr.length; i++) {
		arr[i] = i+1;
		//out.print(arr[i] + "<br>");
%>
	<%=arr[i] + "<br>" %>
<%
	}
%>

</body>
</html>

 

 

 

while문

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>while</title>
</head>
<body>
	<form action="07.2.while.jsp">
	반복하고 싶은 문구 : <input name="msg"><br>
	반복하고 싶은 횟수 : <input type="number" name="count"><br>
	<button>서버로 전송</button>
	</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>while_2</title>
</head>
<body>
<%
	request.setCharacterEncoding("utf-8");
	String msg = request.getParameter("msg");
	int count = Integer.parseInt(request.getParameter("count"));
	int num = 0;
	while(count > num) {
%>
		<%=msg %><br>
<%
		++num;
	}
%>
</body>
</html>

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16
[JavaSpring] page_info  (0) 2024.07.16
[JavaSpring] if문  (0) 2024.07.15
[JavaSpring] Hello JavaSpring  (0) 2024.07.15

[JavaSpring] if문

컴퓨터/JSP
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>if_2</title>
<%! String msg; %>
<%
	request.setCharacterEncoding("UTF-8");
	String name = request.getParameter("name");
	String color = request.getParameter("color");
	/* 
	switch(color) {
	case "blue":
		msg = "파란색";
		break;
	case "yellow":
		msg = "노란색";
		break;
	case "pink":
		msg = "핑크색";
		break;
	case "etc":
		msg = "기타";
	}
	 */
	 
	if(color.equals("blue")) 
		msg = "파란색";
	else if(color.equals("green")) 
		msg = "초록색";
	else if(color.equals("pink")) 
		msg = "핑크색";
	else if(color.equals("etc")) 
		msg = "기타";
%>
</head>
<body bgcolor="<%=color %>">
	<b><%=name %></b>님이 좋아하는 색상은 <b><%=msg %></b>입니다<br>
</body>
</html>​
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>if_1</title>
</head>
<body>
	<h1>if-else example</h1>
	<form action="05.2.if.jsp">
		이름 : <input name="name"><br>
		좋아하는 색상 : 
		<select name="color">
			<option value="green">초록색</option>
			<option value="yellow">노란색</option>
			<option value="pink">핑크색</option>
			<option value="etc">기타</option>
		</select>
		<input type="submit" value="보내기">
	</form>
</body>
</html>

 

 

'컴퓨터 > JSP' 카테고리의 다른 글

[JavaSpring] page_include  (0) 2024.07.16
[JavaSpring] trimWhitespace, userErrorPage  (0) 2024.07.16
[JavaSpring] page_info  (0) 2024.07.16
[JavaSpring] for문, while문  (0) 2024.07.15
[JavaSpring] Hello JavaSpring  (0) 2024.07.15