Jspでパス取得
今回はJspで各種パスを取得してみます。
<%@ page language="java" contentType="text/html; charset=UTF8"
pageEncoding="UTF8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>パス取得</title>
</head>
<body>
<table border="1">
<tr>
<td>request.getContextPath()</td>
<td><%=request.getContextPath()%></td>
</tr>
<tr>
<td>request.getServletPath()</td>
<td><%=request.getServletPath()%></td>
</tr>
<tr>
<td>request.getRequestURI()</td>
<td><%=request.getRequestURI()%></td>
</tr>
<tr>
<td>request.getRequestURL()</td>
<td><%=request.getRequestURL()%></td>
</tr>
<tr>
<td>request.getServletPath()</td>
<td><%=application.getRealPath("/")%></td>
</tr>
</table>
</body>
</html>
ページのトップへ戻る