{"id":1704,"date":"2016-09-22T05:13:41","date_gmt":"2016-09-22T05:13:41","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=1704"},"modified":"2016-09-22T05:13:41","modified_gmt":"2016-09-22T05:13:41","slug":"what-is-context-path","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/what-is-context-path\/","title":{"rendered":"What is Context Path"},"content":{"rendered":"<p><strong>Context path<\/strong><br \/>\nThe context path is the prefix of a URL path that is used to select the context(s) to which an incoming request is passed. Typically a URL in a Java servlet server is of the format<strong> http:\/\/hostname.com\/contextPath\/servletPath\/pathInfo<\/strong>, where each of the path elements can be zero or more \/ separated elements. <\/p>\n<p><strong>How to get ContextPath<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException \r\n{\r\n  ServletContext servletContext = getServletContext();\r\n  String contextPath = servletContext.getRealPath(File.separator);\r\n  PrintWriter out = response.getWriter();\r\n  out.println(&quot;&lt;br\/&gt;File system context path (in TestServlet): &quot; + contextPath);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Context path The context path is the prefix of a URL path that is used to select the context(s) to which an incoming request is passed. Typically a URL in a Java servlet server is of the format http:\/\/hostname.com\/contextPath\/servletPath\/pathInfo, where each of the path elements can be zero or more \/ separated elements. How to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1704","post","type-post","status-publish","format-standard","hentry","category-servlets"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=1704"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1704\/revisions"}],"predecessor-version":[{"id":1705,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/1704\/revisions\/1705"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=1704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=1704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=1704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}