Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hacky, but doable: map it as <code>&lt;error-page&gt;</code> on an <code>&lt;error-code&gt;</code> of <code>404</code>.</p> <pre><code>&lt;servlet&gt; &lt;servlet-name&gt;errorServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;com.example.ErrorServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;errorServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/error&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;error-page&gt; &lt;error-code&gt;404&lt;/error-code&gt; &lt;location&gt;/error&lt;/location&gt; &lt;/error-page&gt; </code></pre> <p>You might want to change the status code in the servlet whenever you want to return a "valid" response.</p> <p>An alternative is to let the Spring servlet listen on a more specific <code>url-pattern</code>. E.g. <code>/pages/*</code>. You could then if necessary bring a <code>Filter</code> in front (on <code>/*</code>) which does roughly the following:</p> <pre><code>if (new File(servletContext.getRealPath(request.getRequestURI())).exists()) { chain.doFilter(request, response); } else { request.getRequestDispatcher("/pages" + request.getRequestURI()).forward(request, response); } </code></pre> <p>so that you don't see/need <code>/pages</code> in the URL.</p> <hr> <p><strong>Update</strong>: as per your new question:</p> <blockquote> <p>UPDATE: What about URL rewriting? Does GlassFish provide any degree of flexibility like Apache does with mod_rewrite? That way I could intercept things before it even reaches the servlet mapping stage.</p> </blockquote> <p>The JSP/Servlet equivalent of Apache HTTPD's <code>mod_rewrite</code> addon is the <a href="http://code.google.com/p/urlrewritefilter/" rel="nofollow">Tuckey's <code>UrlRewriteFilter</code></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload