Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Another newbie-9.x-user question

John,

This is as easy as setting up a ROOT webapp (just a directory, not a war) and defining a 404 page within the web.xml. For example:

JETTY_BASE
     |_webapps
        |_ROOT
           |_WEB-INF
              |_web.xml

Inside this web.xml, you define a simple webapp that, in this case, just serves up an error page:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
   xmlns="http://java.sun.com/xml/ns/javaee
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
   metadata-complete="true"
   version="2.5"> 
  <display-name>Simple WebApp</display-name>
  
  <error-page>
    <error-code>404</error-code>
    <location>/error404.html</location>
  </error-page>
</web-app>

This will set up a 404 page that is served when no a request is not matched to a particular webapp/context. All requests to correctly mapped virtual hosts will be handled by their designated webapp/context.

Best,
Chris

On Wed, Feb 1, 2017 at 7:52 AM, John English <john.foreign@xxxxxxxxx> wrote:
On 01/02/2017 12:52, Simone Bordet wrote:
Do you have a webapp that answers to the 127.0.0.2 virtual host (or
that has no virtual hosts and therefore answers to them all) ?

If not, because you always use specific virtual hosts for your
webapps, then you can have a super-simple webapp deployed at "/" with
no virtual hosts whose only page displays a 404 message.

If I understand correctly, you're saying that I should have my webapp at "/" for a selected set of virtual hosts, and another "404" webapp at "/" for all the others that just returns a 404 for all requests. What do I need to do to make this happen? In particular, what do I need to do to stop the "404" webapp taking precedence and responding to all the requests, including the ones sent to the valid virtual hosts?

Also, why do I get zero bytes in Jetty 9.4 rather than the old Jetty-supplied 404 page that I get with Jetty 8 (as a result of the default webapp, IIRC)?

Many thanks,
--
John English

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top