<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" %>

<html>
<head>
<title> login.jsp </title>
</head>
<body>

<center>
	<h2>로그인</h2>
	<form name="form1" method="post" action="selProduct.jsp">
		<input type="text" name="username"/>
		<input type="submit" value="로그인"/>
	</form>
</center>

</body>
</html>


<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" %>

<html>
<head>
<title> selProduct.jsp </title>
</head>
<body>

<%
	//HTML 폼에서 전달된 데이터의 한글 인코딩
	request.setCharacterEncoding("euc-kr");

	//session에 username 이름으로 HTML 폼의 <input type="text" name="username" />에 입력된 값을 저장함.
	session.setAttribute("username",request.getParameter("username"));
%>

<center>
	<h2>상품 선택</h2>
	<hr>
	<%=session.getAttribute("username") %>님이 로그인한 상태입니다.
	<form name="form1" method="post" action="add.jsp">
		<select name="product">
			<option>사과</option>
			<option></option>
			<option>파인애플</option>
			<option>자몽</option>
			<option>레몬</option>
		</select>
		<input type="submit" value="추가"/>
	</form>
	<a href="checkOut.jsp">계산</a>
</center>

</body>
</html>


<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" import="java.util.ArrayList" %>

<html>
<head>
<title> add.jsp </title>
</head>
<body>

<%
	//HTML 폼에서 전달된 데이터의 한글 인코딩
	request.setCharacterEncoding("euc-kr");

	String productname = request.getParameter("product");
	ArrayList list = (ArrayList) session.getAttribute("productlist");
	if(list == null){
		list = new ArrayList();
	}
	list.add(productname);
	session.setAttribute("productlist",list);
%>

	<script>
		alert("<%=productname %>이(가) 추가되었습니다!!");
		history.go(-1);
	</script>

</body>
</html>


<%@ page language="java" contentType="text/html; charset=euc-kr" pageEncoding="euc-kr" import="java.util.ArrayList" %>

<html>
<head>
<title> checkOut.jsp </title>
</head>
<body>

<center>
<h2>계산</h2>
선택한 상품 목록
<hr>
<%
	ArrayList list = (ArrayList) session.getAttribute("productlist");
	if(list == null){
		out.println("선택한 상품이 없습니다.!!!");
	}
	else {
		for(Object productname:list){
			out.println(productname+"<br>");
		}
	}
%>

</body>
</html>

2008/10/30 14:15 2008/10/30 14:15

Trackback URL : http://mysilpir.net/trackback/329

Leave a comment

« Previous : 1 : ... 4 : 5 : 6 : 7 : 8 : 9 : 10 : 11 : 12 : ... 270 : Next »

블로그 이미지

일상의 이야기를 나누는 공간입니다.

- 실피

Calendar

    «   2009/01   »
            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

Total 157573 hit (Today 18, Yesterday 185)

Admin Write Post