<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String cnt_ = request.getParameter("cnt");
int cnt = 50;
if (cnt_ != null && !cnt_.equals("")) {
cnt = Integer.parseInt(cnt_);
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
안녕
<% for(int i = 0; i<cnt; i++) { %>
안녕 Servlet<br>
<% } %>
</body>
</html>
http://localhost:9090/basic.jsp
form 태그
를 사용하지 않고 get방식
사용하기<%
String cnt_ = request.getParameter("cnt");
int cnt = 50;
if (cnt_ != null && !cnt_.equals("")) {
cnt = Integer.parseInt(cnt_);
}
%>
http://localhost:9090/basic.jsp?cnt=3
Servlet / JSP