title: Prevent the user from making a GET request to a page
body: <p>I am sorry if my question does not make any sense. So here is what I have: 2 pages, <code>A.jsf</code> and <code>B.jsf</code>. When I press a button in <code>A.jsf</code>, the code set the value of an <code>object</code> and redirect to <code>B.jsf</code>. Contain of <code>B.jsf</code> will depend on which object I set in <code>A.jsf</code> (which depend on which button I click). Therefore, I dont want to allow the user to type this on the web browser</p>
  
  <p><a href="http://myhost:myport/myproject/B.jsf" rel="nofollow noreferrer">http://myhost:myport/myproject/B.jsf</a></p>
  
  <p>and get directly to <code>B.jsf</code>. So, no GET request to <code>B.jsf</code>, only POST. And if I see GET request to <code>B.jsf</code>, I redirect to <code>A.jsf</code>. I feel like the solution is inside <code>web.xml</code>.<br>
  btw, I am using Netbean 6.8 and java EE 6</p>
  
  <p><strong>EDIT</strong>
  Here is the solution. Thanks to BalusC<br>
  <code>MyFilter.java</code></p>
  
  <pre><code>package org.xdrawings.filter;
  
  public class MyFilter implements Filter{
  
      private FilterConfig filterConfig = null;
  
      public void destroy(){}
  
      public void init(FilterConfig filterConfig){
          this.filterConfig = filterConfig;
      }
  
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{
          HttpServletRequest req = (HttpServletRequest)request;
          HttpServletResponse res = (HttpServletResponse) response;
          if("GET".equals(req.getMethod()) &amp;&amp; "/B.jsf".equals(req.getServletPath())){
              res.sendRedirect("A.jsf");
          }else {
              chain.doFilter(request, response);
          }
      }
  }
  </code></pre>
  
  <p>then in my <code>web.xml</code></p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;My Filter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.xdrawings.filter.MyFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;My Filter&lt;/filter-name&gt;
      &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p><code>All credits go to BalusC</code></p>