html에 java 코드를 사용하기 위한 태그
- JSP 태그의 종류
html 내부 - java 를 사용 <%@ %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
jsp 내부에 jsp 파일 포함시키기
<%@ include file = "header.jspf" %>
<%@ include file = "footer.jspf" %>
<%! %> 클래스 기능 <% %> 매서드 기능 <%= %>
<%! //클래스
public int i;
public String str = "홍길동";
public int add(int n1, int n2){
return n1 + n2;
}
%>
<% int age = name(); %>
<% //매서드
double a = Math.random();
int result = add(3,2);
int j = 0;
String name= "민준";
%>
<%=name%>입니다.
html 파일 안에 for문을 사용하기
<%for(int i = 0 ;i <10 ; i ++){ %>
<a href = "https://www.naver.com">네이버ㅎ</a>
<%} %>
주석 사용에 따른 - 소스 노출의 유무
<!-- 소스보기 노출 o-->
<%-- 소스보기 노출 x --%>
</body>
</html>