On Wed, Feb 19, 2014 at 7:37 PM, André Warnier <a...@ice-sa.com> wrote:

> Randeep wrote:
>
>> Hi,
>>
>> I'm using tomcat apache-tomcat-6.0.37
>> I have a few web applications in webapps directory.
>>
>> portal
>> sms
>> crm
>>
>> I'm creating custom error pages.
>>
>> inside the webapplication "portal" under WEB-INF in web.xml I have given
>> the following.
>>
>> <error-page>
>> <error-code>400</error-code>
>> <location>/lp/404.html</location>
>> </error-page>
>> <error-page>
>> <error-code>404</error-code>
>> <location>/lp/404.html</location>
>> </error-page>
>> <error-page>
>> <error-code>500</error-code>
>> <location>/lp/oops.html</location>
>> </error-page>
>> <error-page>
>> <exception-type>java.lang.Throwable</exception-type>
>> <location>/lp/oops.html</location>
>> </error-page>
>>
>> And is working fine for the errors like
>>
>> domain.com/portal/sdgggdhsh
>>
>> But for other web applications, obviously it wont work. because I haven't
>> configured in their web.xml files.
>>
>> Is there any way I can give common error pages?
>> I can see that there is a web.xml file under conf directory. And I have
>> given the settings in it. As below.
>>
>> <error-page>
>> <error-code>400</error-code>
>> <location>/404.html</location>
>> </error-page>
>> <error-page>
>> <error-code>404</error-code>
>> <location>/404.html</location>
>> </error-page>
>> <error-page>
>> <error-code>500</error-code>
>> <location>/oops.html</location>
>> </error-page>
>> <error-page>
>> <exception-type>java.lang.Throwable</exception-type>
>> <location>/oops.html</location>
>> </error-page>
>>
>> Path I changed. starting from "/" and put the files in webapps directory.
>> But it is not working.
>>
>> How can I do this?
>>
>
> After a search in Google for "tomcat error-page location", I found this :
> http://stackoverflow.com/questions/3856145/empty-page-
> instead-of-custom-tomcat-error-page
>
> which seems to say that Tomcat will always prefix the given <location>
> with the
> context path of the application where the error happens.
> (For example, if you have <location>/oops.html</location, and if the
> error happens in your app "/MyApp", then Tomcat will be looking for the
> file ...webapps/MyApp/oops.html).
>
> So you cannot have one "generic" location for these error pages, and share
> them for all applications. You have to add the error page to each deployed
> application, separately.
>
> More precisely : you can *define* the error pages, as you have done, in
> the generic conf/web.xml.  But you still have to put a copy of the pages
> themselves in each application separately.
> I suppose that this obeys the general principle according to which each
> application should be self-contained.
>
> Maybe in later Tomcat versions, there would be a way around this via
> aliases or the likes, but it is probably still not recommended.
>
>
> Note also, separately : the URL path "/" resolves to ".../webapps/ROOT/",
> not to ".../webapps/".
>
> Thank you for the reply Andre. I'll add in all the webapps separately.

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


-- 
Randeep
Mob: +919447831699[kerala]
Mob: +919880050349[B'lore]
I blog here:
http://www.randeeppr.me/
Follow me Here:
http://twitter.com/Randeeppr
Poke me here!
http://www.facebook.com/Randeeppr
A little Linux Help
http://www.linuxhelp.in/
Work profile:
http://in.linkedin.com/in/randeeppr

Reply via email to