WEB/JSP

[JSP] ch02-04. Parameter(파라미터)

밍글링글링 2017. 11. 1.
728x90

2-4. Parameter(파라미터) IN / OUT

paraGetIn.html

<!DOCTYPE html>
<html lang="ko">
<head>
<title>HTML</title>
<meta charset="utf-8">
</head>
<body>
<form action="paraOut.jsp">
    <label>사용자명<input type="text" name="userName"/></label><br>
    <label>숫자1<input type="number" name="num1"/></label><br>
    <label>숫자2<input type="number" name="num2"/></label>
    <input type="submit"/>
</form>
</body>
</html>
 

paraOut.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
    String userName = request.getParameter("userName");
    String num1Str = request.getParameter("num1");
    String num2Str = request.getParameter("num2");
    
    int num1 = Integer.parseInt(num1Str);
    int num2 = Integer.parseInt(num2Str);
%>
<%= userName%>이 요청한 게산 결과는<br>
<%= num1%> + <%=num2%>=<%=num1+num2%>
 

728x90

'WEB > JSP' 카테고리의 다른 글

[JSP] ch02-06. Target  (0) 2017.11.09
[JSP] ch02-05.Pameter(파라미터) 2  (0) 2017.11.02
[JSP] ch02-03. Import  (0) 2017.11.01
[JSP] ch02-02. declaration  (0) 2017.11.01
[JSP] ch02-01. scriptlet  (0) 2017.11.01

댓글