JSP 기초

ColinSong·2021년 1월 2일
0

WebApplicationServer

목록 보기
18/26
post-thumbnail

목차

JSP 기초

  • basic.jsp
<%@ 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>

1. 결과

http://localhost:9090/basic.jsp

2. 결과

  • 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

References

  • 뉴렉처: Servlet / JSP
  • 🎈vscode 정리
  • 🎈2021.01.01

profile
안녕하세요:)

0개의 댓글