<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>testForm1.jsp 페이지</h1>
<hr>
<form action="testPro1.jsp" method="get">
<input type="text" name="num"><br>
<input type="submit" value="전송">
</form>
</body>
</html>
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- http://localhost/jspstudy/jsp2/testPro1.jsp?num=5 -->
<!-- request 객체 : 요청정보를 저장하는 객체 -->
<!-- request 파라미터정보 가져오기 .getParameter("파라미터이름") -->
<%
String strNum = request.getParameter("num");
// String형 -> 정수형
int num = Integer.parseInt(strNum);
%>
파라미터값 문자열 : <%=strNum %><br>
파라미터값 문자열+10 : <%=strNum + 10 %><br>
파라미터값 숫자+10 : <%=num + 10 %><br>
</body>
</html>
'IT > Jsp' 카테고리의 다른 글
jsp - form값 post로 submit전송 (text, radio, select, checkbox), value값이 여러개일 때 getParameterValues (0) | 2018.09.11 |
---|---|
jsp - form 태그에서 서버로 값 넘길 때 한글깨짐 처리 (get, post 방식) (0) | 2018.09.03 |
jsp - 스크립틀릿(scriptlet), 선언문, out.println, (0) | 2018.09.02 |
jsp - include, jspf (0) | 2018.09.01 |
jsp, java, 오라클, db 연결해서 json 출력하기 (0) | 2018.08.23 |