3

We have a filter that redirects user to error.html, if the user is not authorized. Right now, we are keeping error.html page inside the WAR, but is there any way to make the html file public so that every war file can access this error page? It would be still better, if we make this html page as a jar and keep it in server/default/lib.

Here is the sample that is used in filter.

 `reqDespacher = request.getRequestDispatcher("error.html")`

and the accessing url is

http://localhost/Context_root/error.html

Any help would be appreciated.

CoolBeans
  • 20,654
  • 10
  • 86
  • 101
Bala
  • 1,295
  • 1
  • 12
  • 23

1 Answers1

2

In JBoss5 or JBoss6, you can copy and then define this custom error.html inside the /deployer/jbossweb.deployer/web.xml of the server instance that you are running. This will require a reboot of the JBoss instance. Example for error code 404:

<error-page>
            <error-code>404</error-code>
            <location><relative_path_to_error_html_file_under_jbossweb.deployer_folder></location>
</error-page>

Secondly, instead of re-directing request by specifying a page manually like you are doing currently, you should use the <error-page> and <error-code> deployment directive to define custom error pages. See specify-the-default-error-page-in-web-xml-in-servlet for a detailed example on how to add error-code directives on web.xml.

For JBoss AS7 global error page configuration take a look at how-to-customize-jboss-as7-404-page .

Community
  • 1
  • 1
CoolBeans
  • 20,654
  • 10
  • 86
  • 101
  • That's not really globally right? What if (in AS 7) I want to customise the 404 shown outside the war/application context? – Kevin R May 30 '13 at 07:48