request 객체는 jsp의 기본객체 중 하나로서 클라이언트의 정보를 저장하고 있는 객체이다.
기본객체이기 때문에 당연히 따로 다른 API를 import 할 필요가 없다.
다음은 request객체를 통해 각종 클라이언트 정보들을 출력해보는 코드이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<%@ 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>
여기는 test폴더<br>
클라이언트 IP : <%=request.getRemoteAddr() %><br>
요청 인코딩 : <%=request.getCharacterEncoding() %><br>
전송방식 : <%=request.getMethod() %><br>
요청URI : <%=request.getRequestURI() %><br>
컨텍스트패스 : <%=request.getContextPath() %><br>
서버명 : <%=request.getServerName() %><br>
포트 : <%=request.getServerPort() %><br>
<%String a = request.getParameter("a"); %>
<%String b = request.getParameter("b"); %>
</body>
</html>
|
cs |
<결과>
'JSP(JavaServerPage)' 카테고리의 다른 글
WEB-INF에 JSP 파일을 놓는 이유 (0) | 2022.07.22 |
---|---|
[JSP] - 쿠키와 세션(Cookie and Session) (0) | 2020.10.15 |
[JSP] - jsp에서 java 클래스를 import 하는 방법 (0) | 2020.10.15 |
[Jsp] - java.lang.ClassNotFoundException: org.mariadb.jdbc.Driver 에러(DB연동) (1) | 2020.10.15 |
[JSP] - JSP 기초 (0) | 2020.10.06 |