반응형
*JSP tag's
-
<%@ %> : 지시자(directive) -page: JSP페이지 환경설정/ -include : 다른 jsp를 끼워 넣을 때
-
<%! %> : 선언(declaration) - instance 변수를 작성, method선언=>class field에 정의된 코드
-
<% %> : 스크립틀릿(scriptlet) - method내의 코드 작성=>지역변수, 제어문, 연산자
-
<%= %> : 표현식(Expression) - web browser에 출력
-
<%-- --%> : 주석(Comment) - JSP tag의 실행을 막을때
-
중첩정의는 되지 않는다. (주석만 가능)
-표현식)
-
<%= %>
-
Web browser에 출력
-
값을 하나만 출력할 수 있다.(연산도 가능) 하지만 <%=i,j%>이런건 불가
-
_jspService method 내 코드로 생성되면서 out.println( );으로 출력되기 때문에 Argument가 하나
-
값에는 ;을 붙일 수 없다.(arguments)
//JSP는 DD가 전혀 필요가 없다. (DD: deployment descriptor)
//C:\dev\apache-tomcat-8.5.37\lib\jasper.jar
//C:\dev\apache-tomcat-8.5.37\lib\servlet-api.jar
//위의 Library가 쓰이며 값을 바꾸어 준다.?값을출력으로 ?
<%@ 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>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<%
//scriptlet
String name="김";
String addr="서울시 강남구";
%>
<ul>
<li>이름 : <%= name %></li>
<li>주소 : <%= addr %></li>
</ul>
<br/>
<!-- Expression에서는 값을 하나만 출력할 수 있다. -->
<%-- <%= name, addr %> 오류남..--%>
<!-- Expression에서는 ; 을 사용할 수 없다. -->
<%-- <%= name; %> --%>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
-선언[declaration]) //디클레이션
-
<%! %> : 정의되는 코드는 class field에 생성된다.
-
*선언 내에서는 내장객체를 사용할 수 없다.(Argument로 전달 받으면 사용은 가능)
-
<%!
-
int i;
-
public void test(){
-
}
-
%>
-
=====>
-
class Test extends HttpJspBase{
-
//이안으로 !의 내용이 들어온다.
-
public void _jspService(HttpServletRequest, HttpServletResponce{
-
//자동으로 생성되는 객체(내장객체)
-
-
}
-
//코드를 보면 HttpJspBase의 출력 부분 중간에 덜렁
-
public void test(){
-
}
-
이렇게 들어가기 때문에 ㄴㄴㄴ
<%@ 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>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<%!//느낌표를 지우면 지역변수가 되서 초기화를 꼭 해주어야 되게 된다.
int i;//instance 변수(자동초기화)
public String name(){
return "공";
}//name
/* public String ip(){
//declaration에서는 내장객체를 사용할 수 없다.
String ip=request.getRemoteAddr();
return ip;
}//ip */
%>
<%!/* 선언부분에서는 출력도 할수 없음.. */
public void test(){
int j=0;
%>
<%-- <%=j %> :declaration사이에서 정의된 코드지만 생성되는 위치가 달라 출력할 수 없다.--%>
<%! /* 닫을때도 선언 부분이어야 method가 잘만들어 진다. */
}//test
%>
i=<%=i %><br/>
이름 :<%=name() %>
<%
//request : 내장(내제) 객체- _jspService method안에서 자동으로 선언되어있는 객체
String ip=request.getRemoteAddr();
%>
접속자 IP Address : <%=ip %>
<%-- <%
/* public void test(){
//메소드는 중첩정의가 안되기 때문에~x
} */
%> 아예 문서로 바꿔주질 않는다. 태그의 실행자체를 막는것--%>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%!
/**
라디오 버튼을 생성하는 method<br/>
createRadio(라디오버튼갯수, 라디오버튼이름,기본체크 값(라디오버튼보다 크면 안된다.))
*/
public String createRadio(int rCnt, String rName, int rDefault){
StringBuilder radio=new StringBuilder();
if(rCnt<rDefault){
rDefault=0;
}//end if
for(int i=0; i<=rCnt; i++){
radio.append("<input type='radio'name='").append(rName)
.append("' value='").append(i).append("'");
if(i==rDefault){
radio.append("checked='checked'");
}//end if
radio.append(">").append(i).append("점 ");
}//end for
return radio.toString();
}//createRadio
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
#nameTitle{width:100px;}
#scoreTitle{width:500px;}
table{border-top:2px solid #333; }
th{height: 30px}
th,td{border-bottom:1px dotted #4F4F4F; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<%
String[] names={"공","김","이","정"};
%>
<table>
<tr>
<th id="nameTitle">이름</th>
<th id="scoreTitle">점수</th>
</tr>
<% for(int i=0; i<names.length; i++){%>
<tr>
<td><%=names[i] %></td>
<td>
<%-- <%for (int j=0; j<11; j++){ %>
<input type="radio" name="score_<%=i%>"value="<%=j %>"/><%=j %>점
<%}//end for %> --%>
<%=createRadio(10,"name_"+i,5) %>
</td>
</tr>
<% }//end for%>
</table>
전체 점수 : <%=createRadio(10,"total",0) %>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
-Comment)
-
JSP tag의 실행을 막을 때 사용
-
<%-- --%> : 감싸고 있는 JSP tag의 코드 생성을 막는 일
-
<%--
-
<%!
-
%>
-
<%
-
<%>
-
--%>
-지시자(directive) )
-
<%@ %>
-
페이지 지시자 : JSP파일 첫줄에 기술
-
//어디에 정의되어있어도 전혀 상관이 없다. 위에다 넣는게 페이지를 열었을때 의미적으로 보기 편하기 때문.
-
형식
-
<%@ page 속성="값" %>
-
...
-
<%@ page 속성=:값" 속성명="값"... %>
-
//둘다 가능 /내가 정의하지 않으면 기본으로 기본값을 가짐 /속성명에대해서는 대소문자 구분주의
속성명 |
기본값 |
변경할 값 |
contentType
응답방식설정
(MIME-TYPE) |
"text/html" : 응답 방식 설정
|
web.xml에 정의된 <mime-types>를 참조하여 설정
(WAS : Web Application Server)
text/html;charset=UTF-8 |
pageEncoding |
"8859-1" -jsp파일 자체 Charset |
지원되는 Charset
UTF-8(모든 문자 국제표준), EUC-KR, MS949(모든문자지만 ms사),KSC5601,8859-1 |
info |
" " |
"jsp페이지의 간략한 설명" |
extends |
"HttpJSPBase" jsp가 java로 변경될 때 상속받은 클래스를 설정 |
////바꾸지 않는다.내가 만든(검증안된)것보단 만들어진것 사용
HttpServlet의 자식클래스라면 설정 가능하다. |
★language |
java가 아닌 다른언어의 코드
(Scriptlet에서 자바언어가 아닌 다른 언어를 사용할 때 ) |
OOP를 완벽하게 지원하는 언언어.
OOP: Object Oriented Programming
쓰는거 한번도 못봤다고.. |
★buffer |
"8kb" jsp가 HTML로 변환 될때 출력되는 Stream 크기(스트림이 작을수록 속도 빠름) |
8kb, 16kb, 32kb |
★autoFlush
//잘건들이지 않는다. |
true 출력스트림의 내용 분출여부 |
false(일정크기 이상의 JSP라면 에러가 발생하여 잘안건든다.) |
isThreadSafe |
true : JSP가 Thread처리될 것인지 여부 |
false |
session |
접속자의 정보를 접속자의 메모리에 저장
true : 세션 사용 여부 |
false |
import |
"jsp와 관련된 package import"
필요한 클래스를 가진 패키지를 import할때 |
"java.lang.클래스명"
"java.lang.클래스명,java.util,,,"
|
isELIgnored |
true : jsp에서 EL을 사용할 것인지 여부 |
false EL을 사용하지 않을때 |
errorPage |
"" : jsp에서 에러가 발생했을 때 |
"페이지 URI" |
isErrorPage |
false : 다른 jsp가 Error를 발생했을 때 처리할 페이지 인지 |
true |
Container : Servlet/JSP를 요청하면 HTML로 변환(pageEncoding)
JSP동작)
- 요청>Tomcat에서 .jsp>.java>(compile)>.class>JVM에서 instance>_jspInit()>_JspService()>Tomcat에 HTML을 생성하여 응답
HTML로 만들어진게 MIME-TYPE의 설정에 따라서 응답해 주는것이다.(Content Type)
<!-- 지시자 하나에 여러 속성 사용 -->
<%@page import="java.util.Random"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" info="Page Directive 연습" %>
<%@ page buffer="8kb" autoFlush="true"%>
<%@ page isThreadSafe="true" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat, java.util.Calendar" %>
<%@ page isELIgnored="true" %>
<%@ page errorPage="page_directive1.jsp" %>
<%@ page session="true" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<%
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
String date=sdf.format(new Date());
int year=Calendar.getInstance().get(Calendar.YEAR);
if(new Random().nextBoolean()){
throw new Exception("예외강제 발생!!!");
}//end if
session.setAttribute("name", "정");
%>
<%=date %>,<%=year %>
<div>
<strong>EL(Expression Language)</strong>
<br/>
3+11=${3+11}<br/>
web Prameter: <%=request.getParameter("name") %>
web Prameter: ${param.name}
<br/>
<a href="page_directive.jsp?name=heechul">요청</a>
</div>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isErrorPage="true" %>
<!-- isErrorPage가 false라면 이전페이지에서 발생한 예외를 받을 수 없다. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<img src="../common/images/img.png" title="잘생긴 개발자가 신속하게 처리중"/>
<div>
문제 발생 : 요청하신 페이지에서 문제가 발생했습니다.<br/>
뎨둉합니다..<br/>
에러의 이유 : <%=exception %><!-- false인 경우 exception을 볼수 없다. -->
</div>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
-include 지시자)
-
브라우저에서 여러개의 JSP를 동시에 보여줘야 할때(<jsp:include>,<C:import>) ->보이는건 같으나 아예다르게 쓰임?디자인합치기 좋음..
-
<%@ include file="끼워 넣을 JSP.URI" %>
-
jsp가 하나의 Sorce Code로 만들어 진다.
-
다른 include보다 속도가 빠르다.
-
변수나 method가 공유된다.
-
page지시자의 충돌이 발생할 수 있다.(contentType, pageEncodeing등)=>모든 JSP가 같은 값을 가져야 한다.(아님 Error)
-
많은 jsp에서 공통 Source Code를 병합해야 할때 (세션에 관한 체크)
-
두 jsp파일이 하나의 .java파일이되는데 잘못하다간 page지시자 충돌, 변수충돌, method 명 충돌이 발생할 수 있다.
흐름도)
==>html에 요청이 들어오면 응답을 해주고 이벤트가 발생하여 .jsp에 요청이 들어오면 끼워넣어보여준다.
//CDN : Content delivery network
//$ : jquery object 객체
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="include연습"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<div>
외부 JSP
<%
String name ="김";
%>
<div>
<%@include file="include_b.jsp" %>
</div>
외부 JSP
<br/>
<!-- 외부 JSP에서 끼워지는 JSP의 변수는 에러 없이 사용할 수 있다. -->
나이 : <%=age %>,주소: <%=addr %>
<!-- 변수는공유된다. -->
<%=toDay() %>
</div>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="include연습"
%>
<!-- 끼워지는 JSP에서는 코드가 들어가는 태그의 자식 태그로 들어가기 때문에 <html>은 가지지 않고
포함되는 태그로만 구성한다. -->
<%! public String toDay(){
String toDay="";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd EEEE a HH:mm:ss");
toDay=sdf.format(new Date());
return toDay;
}//toDay
%>
<%
//끼워지는 모든 JSP에서의 공통코드를 정의
int age=10;
String addr="서울시 강남구";
%>
<div>
<strong>끼워지는 JSP</strong>
나이 : <%=age %><br/>
주소 : <%=addr %><br/>
<%--
외부 JSP에서 제공하는 변수는 외부 JSP에 존재할 수도 있고, 존재하지 않을 수도 있다.
따라서 내부 JSP에서 외부 JSP의 변수를 사용하는 코드는 에러를 유발하는 원인이 될 수도 있기 때문에
가급적이면 외부 JSP의 변수를 사용하지 않는다.
<strong>외부 JSP변수 : <%=name %></strong> --%>
</div>
-내장(내재)객체
-
_jspService method 안에 선언된 객체 들
내장 객체명 |
데이터 형 |
하는 일 |
request |
HttpServletRequest |
요청 처리
-접속자가 입력한 값
-접속자의 정보 얻기
-session/cookie얻기 (관계 유지 위한 객체들)
-Forward 이동
-JSP페이지의 값을 저장하는 일 |
response |
HttpServletResponse |
응답 처리
-쿠키 심는 일
-redirect 이동 |
out |
JspWriter |
브라우저에 출력 |
session |
HttpSession |
관계 유지
-JSP 내의 정보를 저장하는 일 |
pageContext |
PageContext |
JSP내 정보를 저장하는 일 |
application |
ServletContext |
JSP내 정보를 저장하는 일 |
exception |
Throwable |
-isErrorPage="true"인 경우에만 제공
-Error든 Exception이든 모두 처리할 수 있다. |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#btnGet").click(function(){//id selector
$("[method='get']").submit(); //attribute selector
});//click
$("#btnLoc1").click(function(){//id selector
location.href="call.jsp";
});//click
$("#btnLoc2").click(function(){//id selector
location.replace("call.jsp");/* 뒤로가기 하면 안될때.. */
});//click
$("#btnPost").click(function(){//id selector
$("[method='post']").submit(); //attribute selector
});//click
});//ready
</script>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<div>
<strong>GET방식으로 JSP요청</strong>
<ul>
<li><a href="call.jsp">GET요청</a></li>
<li>
<form method="get" action="call.jsp">
<input type="button" value="GET방식 요청" class="btn" id="btnGet"/>
</form>
</li>
<li>
<input type ="button" value="location 사용 요청1" class="btn" id="btnLoc1"/>
<input type ="button" value="location 사용 요청2" class="btn" id="btnLoc2"/>
</li>
</ul>
</div>
<div>
<strong>POST방식으로 JSP요청</strong>
<ul>
<li>
<form action="call.jsp" method="post">
<input type="button" value="post요청" class="btn" id="btnPost"/>
</form>
</li>
</ul>
</div>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="HTML에서 JSP를 요청"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
<% if("GET".equals(request.getMethod())){ %>
#method{ font-weight: bold; font-size: 14px; color: #FF0000;}
<% }else{ %>
#method{ font-weight: bold; font-size: 16px; color: #0000FF;}
<%}//end else %>
%>
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<ul>
<li><strong>요청 방식</strong> :
<span id="method"><%=request.getMethod() %></span></li>
<li><strong>접속자 IP Address</strong> : <%= request.getRemoteAddr() %></li>
<li><a href="javascript:history.back();">뒤로</a></li>
</ul>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
*scope객체(pageContext, request, session,application 각각의 영역을 가진다.)-기본영역?
-
=>jsp에서 발생한 값을 저장하고 사용하는 객체
-
객체마다 사용범위가 달라진다.
<<<Request내장객체로 접속자의 정보를 뽑아내는 것>>>
<%@ 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>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/main_v190130.css"/>
<style type="text/css">
#wrap{margin:0px auto;width:800px; height:860px;}
#header{width:800px; height:140px; background:#FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position: relative; }
#headerTitle{font-family: HY견고딕,고딕; font-size:35px; font-weight:bold; text-align:center;
/* padding-top: 35px */ position:absolute; top:40px; left:290px; }
#container{width:800px; height:600px; }
#footer{width:800px; height:120px; }
#footerTitle{float: right; font-size:15px; padding-top:20px; padding-right:20px; }
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4</div>
</div>
<div id="container">
<ul>
<li><strong>요청 URL</strong> : <%= request.getRequestURL() %></li>
<li><strong>요청 Protocol</strong> : <%= request.getProtocol() %></li>
<li><strong>요청 서버명</strong> : <%= request.getServerName() %></li>
<li><strong>요청 서버 Port</strong> : <%= request.getServerPort() %></li>
<li><strong>요청 URI</strong> : <%= request.getRequestURI() %></li>
<!-- uri=Uniform Resource Identifier -->
<li><strong>요청 서블릿 Path</strong> : <%= request.getServletPath() %></li>
<li><a href="request.jsp?name=jinkyung&addr=gangseogu&age=30">JSP QueryString요청</a></li>
<li><strong>QueryString</strong> : <%= request.getQueryString() %></li>
<li><strong>요청 Parameter</strong> : <%= request.getParameter("name") %></li>
<li><strong>요청 방식</strong> : <%= request.getMethod() %></li>
<li><strong>접속자 IP</strong> : <%= request.getRemoteAddr() %></li>
<li><strong>접속자 PORT</strong> : <%= request.getRemotePort() %></li>
</ul>
</div>
<div id="footer">
<div id="footerTitle">copyright© all right reserved. class 4.</div>
</div>
</div>
</body>
</html>
반응형
'국비지원학원 > JSP' 카테고리의 다른 글
98일차-JSP_JSTL_forTokens (0) | 2019.04.03 |
---|---|
97일차-JSP_JSTL(Jsp Standard Tag Library) (0) | 2019.04.03 |
96일차-JSP_액션태그 (0) | 2019.03.31 |
95일차-JSP_내장 객체 (0) | 2019.03.31 |
93일차-JSP (0) | 2019.03.26 |