{"id":999,"date":"2018-04-15T13:24:40","date_gmt":"2018-04-15T04:24:40","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=999"},"modified":"2023-05-27T20:46:22","modified_gmt":"2023-05-27T11:46:22","slug":"%e3%80%90%e3%82%b5%e3%83%bc%e3%83%96%e3%83%ac%e3%83%83%e3%83%88%e3%80%91%e3%82%b5%e3%83%bc%e3%83%96%e3%83%ac%e3%83%83%e3%83%88%e3%83%95%e3%82%a3%e3%83%ab%e3%82%bf%e3%81%ae%e5%88%a9%e7%94%a8%e3%81%ab","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=999","title":{"rendered":"\u3010\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u3011\u5171\u901a\u51e6\u7406\u3092\u66f8\u304f\u306b\u306f\uff1f\uff08\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u306e\u5229\u7528\uff09"},"content":{"rendered":"<h2>\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u3068\u306f\uff1f<\/h2>\n<p>\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u3084\u3001JSP\u306b\u304a\u3044\u3066<strong>\u300c\u5171\u901a\u306e\u524d\u5f8c\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u300d<\/strong>\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<h2>\u7528\u9014<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u60f3\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u5165\u529b\u6587\u5b57\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u3059\u308b\u3002<\/li>\n<li>\u30bb\u30c3\u30b7\u30e7\u30f3\u5207\u308c\u306e\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\u3002<\/li>\n<li>\u8a8d\u8a3c\u51e6\u7406<\/li>\n<li>\u30ed\u30ae\u30f3\u30b0\u51e6\u7406<\/li>\n<li>\u5171\u901a\u30c7\u30fc\u30bf\u5909\u63db<\/li>\n<\/ul>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306a\u51e6\u7406\u306f\u3001\u3069\u306e\u753b\u9762\u3067\u3082\u5171\u901a\u3067\u3059\u3057\u3001\u3046\u3063\u304b\u308a\u629c\u3051\u6f0f\u308c\u304c\u3042\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3092\u9632\u3044\u3067\u304f\u308c\u308b\u306e\u304c\u3001\u300c<span style=\"color: #ff0000;\"><strong>\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf<\/strong><\/span>\u300d\u3068\u3044\u3046\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n<h2>\u4f7f\u3044\u65b9<\/h2>\n<h3>1.javax.servlet.Filter\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3092\u5b9f\u88c5\u3057\u305f\u30d5\u30a3\u30eb\u30bf\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/h3>\n<p>\u300cjavax.servlet.Filter\u300d\u3068\u3044\u3046\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306e\u5b9f\u88c5\u30af\u30e9\u30b9\u3092\u4f5c\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4e0b\u8a18\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u5b9f\u88c5\u3055\u308c\u3066\u304a\u308a\u3001<strong>\u51e6\u7406\u306e\u3042\u308b\u306a\u3057\u306b\u95a2\u308f\u3089\u305a\u3001\u30e1\u30bd\u30c3\u30c9\u3092\u8a18\u8ff0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<th>\u30e1\u30bd\u30c3\u30c9\u540d<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>init<\/td>\n<td>\u521d\u671f\u5316\u6642\u306b\u4e00\u56de\u3060\u3051\u547c\u3070\u308c\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>doFilter<\/td>\n<td>\u30d5\u30a3\u30eb\u30bf\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>destroy<\/td>\n<td>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u524a\u9664\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0(Tomcat\u505c\u6b62\u6642)\u3067\u3001\u4e00\u5ea6\u3060\u3051\u547c\u3070\u308c\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u30b5\u30f3\u30d7\u30eb<\/h4>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1018\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/04\/\u30d5\u30a3\u30eb\u30bf\u30fc1.png\" alt=\"\" width=\"180\" height=\"54\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/04\/\u30d5\u30a3\u30eb\u30bf\u30fc1.png 180w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/04\/\u30d5\u30a3\u30eb\u30bf\u30fc1-177x54.png 177w\" sizes=\"(max-width: 180px) 100vw, 180px\" \/><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage filter;\r\n\r\nimport java.io.IOException;\r\n\r\nimport javax.servlet.Filter;\r\nimport javax.servlet.FilterChain;\r\nimport javax.servlet.FilterConfig;\r\nimport javax.servlet.ServletException;\r\nimport javax.servlet.ServletRequest;\r\nimport javax.servlet.ServletResponse;\r\n\r\npublic class FilterTest implements Filter{\r\n\r\n    public void init(FilterConfig filterConfig)\r\n    throws ServletException {\r\n    \tSystem.out.println(&quot;\u521d\u671f\u51e6\u7406\u3067\u3059\u3002&quot;);\r\n\t}\r\n\r\n\tpublic void doFilter(ServletRequest request,\r\n\t    ServletResponse response, FilterChain chain)\r\n\t    throws IOException, ServletException {\r\n\r\n\t\trequest.setCharacterEncoding(&quot;UTF-8&quot;);\r\n\t\tSystem.out.println(&quot;\u5171\u901a\u51e6\u7406\u3067\u3059\u3002&quot;);\r\n\t\tchain.doFilter(request, response);\r\n\r\n\t}\r\n\r\n\tpublic void destroy() {\r\n\t\t\/\/\u4f55\u3082\u3057\u306a\u3044\u3002\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h3>2.web.xml\u306b\u30d5\u30a3\u30eb\u30bf\u767b\u9332\u3092\u3059\u308b\u3002<\/h3>\n<p>\u5177\u4f53\u7684\u306a\u66f8\u304d\u65b9\u306f\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"tLkTSYgQP8\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=926\">\u3010Tomcat\u3001\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u958b\u767a\u3011web.xml\u306e\u66f8\u304d\u65b9<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=926&#038;embed=true#?secret=tLkTSYgQP8\" data-secret=\"tLkTSYgQP8\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Tomcat\u3001\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u958b\u767a\u3011web.xml\u306e\u66f8\u304d\u65b9&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h4>\u30b5\u30f3\u30d7\u30eb<\/h4>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n\r\n&lt;web-app xmlns=&quot;http:\/\/java.sun.com\/xml\/ns\/javaee&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd&quot; version=&quot;2.5&quot;&gt;\r\n\r\n   \t&lt;servlet&gt;\r\n\t\t&lt;servlet-name&gt;hello&lt;\/servlet-name&gt;\r\n\t\t&lt;servlet-class&gt;HelloServlet&lt;\/servlet-class&gt;\r\n\t&lt;\/servlet&gt;\r\n  \t&lt;servlet-mapping&gt;\r\n    \t&lt;servlet-name&gt;hello&lt;\/servlet-name&gt;\r\n    \t&lt;url-pattern&gt;\/HelloServlet&lt;\/url-pattern&gt;\r\n  \t&lt;\/servlet-mapping&gt;\r\n\r\n\t&lt;filter&gt;\r\n\t\t&lt;filter-name&gt;SampleFilter&lt;\/filter-name&gt;\r\n\t\t&lt;filter-class&gt;filter.FilterTest&lt;\/filter-class&gt;\r\n\t&lt;\/filter&gt;\r\n\r\n\t&lt;filter-mapping&gt;\r\n\t\t&lt;filter-name&gt;SampleFilter&lt;\/filter-name&gt;\r\n\t\t&lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\r\n\t&lt;\/filter-mapping&gt;\r\n\r\n&lt;\/web-app&gt;\r\n<\/pre>\n<h2>\u5b9f\u884c\u7d50\u679c<\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1021\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/04\/\u30d5\u30a3\u30eb\u30bf\u30fc\uff12.png\" alt=\"\" width=\"140\" height=\"54\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u30d5\u30a3\u30eb\u30bf\u3068\u306f\uff1f \u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u3084\u3001JSP\u306b\u304a\u3044\u3066\u300c\u5171\u901a\u306e\u524d\u5f8c\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u300d\u306e\u3053\u3068\u3067\u3059\u3002 \u7528\u9014 \u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u60f3\u5b9a\u3067\u304d\u307e\u3059\u3002 \u5165\u529b\u6587\u5b57\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u3059\u308b\u3002 \u30bb\u30c3\u30b7\u30e7\u30f3\u5207\u308c\u306e\u30c1\u30a7\u30c3 [&hellip;]","protected":false},"author":1,"featured_media":1094,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/999"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=999"}],"version-history":[{"count":20,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/999\/revisions"}],"predecessor-version":[{"id":20260,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/999\/revisions\/20260"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/1094"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=999"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}