form.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
	<h1>다음에 좌표값을 입력 하세요.</h1>
	<form action="./action.jsp">
		<div>
			<label for="x">x : </label>
			<input type="text" name="x">
		</div>
		<div>
			<label for="y">y : </label>
			<input type="text" name="y">
		</div>
		<button type="submit">전송</button>
	</form>
</body>
</html>

service/Point.java

package service;

public class Point {
	public String x;
	public String y;
}

action.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import="service.Point" %>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
	<%
		Point point = new Point();
		point.x = request.getParameter("x");
		point.y = request.getParameter("y");
	%>
	<h3>form.jsp에서 넘겨받은 좌표값</h3>
	<table	>
		<thead>
			<tr>
				<td>x</td>
				<td>y</td>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><%=point.x%></td>
				<td><%=point.y%></td>
			</tr>
		</tbody>
	</table>
</body>
</html>

+ Recent posts