2017.04.20부터 네이버 블로그와 같이 운영 할 예정입니다!
앞으로도 꾸준히 자주 올릴게요!
티스토리/TISTORY: shallotic.tistory.com
네이버 블로그: blog.naver.com/rmlfa96
(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-8242763509535969", enable_page_level_ads: true });
2017.04.20부터 네이버 블로그와 같이 운영 할 예정입니다!
앞으로도 꾸준히 자주 올릴게요!
티스토리/TISTORY: shallotic.tistory.com
네이버 블로그: blog.naver.com/rmlfa96
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | package test; import java.awt.TextArea; public class BeanTest { String my_id; String my_pwd; String my_pwd1; String my_add; String my_name; String my_num; int my_year; int my_month; int my_date; String[] hobby; String my_intro; public String getMy_id() { return my_id; } public void setMy_id(String my_id) { this.my_id = my_id; } public String getMy_pwd() { return my_pwd; } public void setMy_pwd(String my_pwd) { this.my_pwd = my_pwd; } public String getMy_pwd1() { return my_pwd1; } public void setMy_pwd1(String my_pwd1) { this.my_pwd1 = my_pwd1; } public String getMy_add() { return my_add; } public void setMy_add(String my_add) { this.my_add = my_add; } public String getMy_name() { return my_name; } public void setMy_name(String my_name) { this.my_name = my_name; } public String getMy_num() { return my_num; } public void setMy_num(String my_num) { this.my_num = my_num; } public int getMy_year() { return my_year; } public void setMy_year(int my_year) { this.my_year = my_year; } public int getMy_month() { return my_month; } public void setMy_month(int my_month) { this.my_month = my_month; } public int getMy_date() { return my_date; } public void setMy_date(int my_date) { this.my_date = my_date; } public String[] getHobby() { return hobby; } public void setHobby(String[] hobby) { this.hobby = hobby; } public String getMy_intro() { return my_intro; } public void setMy_intro(String my_intro) { this.my_intro = my_intro; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <jsp:useBean id="beantest" class="test.BeanTest" scope="page" /> <jsp:setProperty name="beantest" property="*" /> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>회원가입 페이지 정보</title> </head> <body align="center" marginwidth="0" marginheight="10"> <embed src="넌 행복해.mp3"> <form name="f" method="post"> <table width="800" height="250" border="1" align="center"> <tr align="left"> <td align="center" colspan="2" bgcolor="pink"><B>회원 기본 정보</B></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>아이디:</b></td> <td><%=beantest.getMy_id()%></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>비밀번호:</b></td> <td><%=beantest.getMy_pwd1()%></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>비밀번호 확인:</b></td> <td><%=beantest.getMy_pwd()%></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>메일 주소:</b></td> <td><%=beantest.getMy_add()%></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>이름:</b></td> <td><%=beantest.getMy_name()%></td> </tr> <tr> <td align="center" colspan="2" bgcolor="skyblue"><B>개인 신상정보</B></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>주민등록번호:</b></td> <td><%=beantest.getMy_num()%></td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>생일:</b></td> <td><%=beantest.getMy_year()%>년 <%=beantest.getMy_month()%>월 <%=beantest.getMy_date()%>일</td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>관심분야:</b></td> <td> <% String[] hobby1 = request.getParameterValues("hobby"); beantest.setHobby(hobby1); String a1[] = beantest.getHobby(); for (int i = 0; i < a1.length; i++) { out.println(a1[i] + "<br>"); } %> </td> </tr> <tr align="left"> <td align="center" bgcolor="lightgreen"><b>자기소개:</b></td> <td><jsp:getProperty name="beantest" property="my_intro" /> </tr> </table> </form> </body> </html> |
[JSP] 장바구니 1분 지나면 자동적으로 세션 만료하기 (0) | 2017.04.20 |
---|---|
[JSP] 절대경로와 상대경로 (0) | 2017.04.20 |
[JSP] 기본적인 장바구니 만들기 (0) | 2017.04.20 |
[JSP] 자바 빈즈 이용한 예제 (0) | 2017.04.20 |
[JSP]Application, Session, Request 예제 (0) | 2017.04.20 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>Shopping</title> </head> <body> <center> <h2>Shopping</h2> <hr> <form method="post" action=setProduct.jsp> ID : <input type="text" name=Id> <input type="submit" value="확인"> </form> </center> <% session.setAttribute("Id", request.getParameter("Id")); %> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <%@page import="com.sun.java.swing.plaf.windows.resources.windows"%> <%@page import="com.sun.xml.internal.bind.v2.runtime.Location"%> <%@page import="javafx.scene.control.Alert"%> <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>상품선택/Shopping</title> </head> <% if (session.getAttribute("Id") != null) { session.setAttribute("Id", session.getAttribute("Id")); } else { session.setAttribute("Id", request.getParameter("Id")); } %> <% if (session.getAttribute("Id") == null || session.getAttribute("Id") == "") response.sendRedirect("Login.jsp"); %> <% session.setMaxInactiveInterval(60); %> <body> <center> <h2>Shopping</h2> <hr> ${Id}님 환영합니다~!!! <hr> <form name="f1" action="add.jsp" method="post"> <select name=product><option value="딸기">딸기</option> <option value="귤">귤</option> <option value="포도">포도</option> <option value="파인애플">파인애플</option> <option value="사과">사과</option> <option value="수박">수박</option> </select><input type="submit" value="추가"><br> <a href="checkOut.jsp">계산</a> </form> </center> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <%@page import="java.util.ArrayList"%> <%@page import="com.sun.corba.se.spi.orbutil.fsm.Action"%> <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>상품추가/Shopping</title> </head> <% session.setMaxInactiveInterval(60); %> <body> <% String productname = request.getParameter("product"); ArrayList addlist = (ArrayList) session.getAttribute("productlist"); if (addlist == null) { addlist = new ArrayList(); } session.setAttribute("productlist", addlist); addlist.add(productname); %> <% out.println("<script> alert('상품이 추가되었습니다.'); history.go(-1);</script>"); %> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <%@page import="java.util.ArrayList"%> <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>장바구니/Shopping</title> </head> <% if (session.getAttribute("Id") == null || session.getAttribute("Id") == "") response.sendRedirect("Login.jsp"); %> <% session.setMaxInactiveInterval(60); %> <body> <center > <h2>Shopping</h2> <hr> 장바구니에 담겨진 물건들 <hr> <% ArrayList addlist = (ArrayList) session.getAttribute("productlist"); if (addlist == null) { out.println("Empty"+ "<br>"); } else { for (int i = 0; i < addlist.size(); i++) { out.println(addlist.get(i) + "<br>"); } } %> <% session.setAttribute("Id", session.getAttribute("Id")); session.setAttribute("addlist", addlist); %> <input type="button" name=b1 value="뒤로가기" onclick="location.href='setProduct.jsp'"> <input type="button" name=b2 value="로그아웃" onclick="location.href='Login.jsp';session.invalidate();"> </form> </center> </body> </html> |
세션을 자동 중지 하려면 Login.jsp를 제외한 다른 jsp에 <% session.setMaxInactiveInterval(60); %> 추가해주시길 바랍니다.
[JSP] 자바 빈즈를 통해 회원가입 페이지 정보 가져오기 (0) | 2017.04.20 |
---|---|
[JSP] 절대경로와 상대경로 (0) | 2017.04.20 |
[JSP] 기본적인 장바구니 만들기 (0) | 2017.04.20 |
[JSP] 자바 빈즈 이용한 예제 (0) | 2017.04.20 |
[JSP]Application, Session, Request 예제 (0) | 2017.04.20 |
절대경로와 상대경로에 대해 알아봅시다.
우선 절대경로(Absolute)는 전체경로로, 루트 디렉토리부터 지정하는 경로 지정법입니다.
C 드라이브로 시작됩니다.
예를 들어
C:\Users\username\Pictures
C:\Users\username\Desktop\android
과 같은 표기법으로 쓰입니다.
상대경로(Relative)는 현재 디렉토리를 기준으로 지정하는 경로 지정법입니다.
상대 경로는 (1) /:최상의 경로 (2)./현재 폴더를 의미합니다. (3) ../:상위 폴더를 의미합니다.
예를 들어 01_01_html에서 style="background-image: ./벚꽃사진_5.JPG"라고 하면 배경이 벚꽃 사진이 나오겠죠?
[JSP] 자바 빈즈를 통해 회원가입 페이지 정보 가져오기 (0) | 2017.04.20 |
---|---|
[JSP] 장바구니 1분 지나면 자동적으로 세션 만료하기 (0) | 2017.04.20 |
[JSP] 기본적인 장바구니 만들기 (0) | 2017.04.20 |
[JSP] 자바 빈즈 이용한 예제 (0) | 2017.04.20 |
[JSP]Application, Session, Request 예제 (0) | 2017.04.20 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>Shopping</title> </head> <body> <center> <h2>Shopping</h2> <hr> <form method="post" action=setProduct.jsp> ID : <input type="text" name=Id> <input type="submit" value="확인"> </form> </center> <% session.setAttribute("Id", request.getParameter("Id")); %> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>Shopping</title> </head> <body> <center> <h2>Shopping</h2> <hr> <form method="post" action=setProduct.jsp> ID : <input type="text" name=Id> <input type="submit" value="확인"> </form> </center> <% session.setAttribute("Id", request.getParameter("Id")); %> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <%@page import="java.util.ArrayList"%> <%@page import="com.sun.corba.se.spi.orbutil.fsm.Action"%> <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>상품추가/Shopping</title> </head> <body> <% if (session.getAttribute("Id") == null || session.getAttribute("Id") == "") response.sendRedirect("Login.jsp"); %> <% String productname = request.getParameter("product"); ArrayList addlist = (ArrayList) session.getAttribute("productlist"); if (addlist == null) { addlist = new ArrayList(); } session.setAttribute("productlist", addlist); addlist.add(productname); %> <% out.println("<script> alert('상품이 추가되었습니다.'); history.go(-1);</script>"); %> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <%@page import="java.util.ArrayList"%> <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>장바구니/Shopping</title> </head> <body> <% if (session.getAttribute("Id") == null||session.getAttribute("Id")=="") response.sendRedirect("Login.jsp"); %> <center> <h2>Shopping</h2> <hr> 장바구니에 담겨진 물건들 <hr> <% ArrayList addlist = (ArrayList) session.getAttribute("productlist"); if (addlist == null) { out.println("Empty"); } else { for (int i = 0; i < addlist.size(); i++) { out.println(addlist.get(i) + "<br>"); } } %> <% session.setAttribute("Id", session.getAttribute("Id")); session.setAttribute("addlist", addlist); %> <input type="button" name=b1 value="뒤로가기" onclick="location.href='setProduct.jsp'"> <input type="button" name=b2 value="로그아웃" onclick="location.href='Login.jsp';session.invalidate();"> </form> </center> </body> </html> |
'
장바구니에 추가해줬을 때 결과입니다.
장바구니 예제입니다. histoty.go(-1)를 쓴 이유는 바로 전 페이지로 넘어가기 위해서 썼습니다.
로그인이 안 되었을 때 넘어가는 상황들을 모두 response.sendRedirect() 메서드를 이용해 모두 Login.jsp로 넘겼습니다.
또, 로그아웃이 되었을 땐 session을 죽이는 session.invalidate()를 이용합니다.
[JSP] 장바구니 1분 지나면 자동적으로 세션 만료하기 (0) | 2017.04.20 |
---|---|
[JSP] 절대경로와 상대경로 (0) | 2017.04.20 |
[JSP] 자바 빈즈 이용한 예제 (0) | 2017.04.20 |
[JSP]Application, Session, Request 예제 (0) | 2017.04.20 |
[JSP] 템플릿/template과 include를 이용한 예제 (0) | 2017.04.20 |