Re: Single error page for multiple web applications

2014-01-02 Thread Maarten van Hulsentop
Thank you all for your input!
I do realize that our use case is somewhat odd, as we have multiple webapps
that have shared resources and are related in that sense.
For now, we should go for the duplication of resources (using Tomcat 7).
However, the webAppMount option looks like a fair option to me, once we
have migrated to Tomcat 8.

Regards,

Maarten



2014/1/1 Christopher Schultz ch...@christopherschultz.net

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256

 Leo,

 On 12/31/13, 3:58 PM, Leo Donahue wrote:
  On Dec 31, 2013 3:15 AM, Maarten van Hulsentop
  maar...@vanhulsentop.nl wrote:
 
  Hello,
 
  We are using Tomcat to host a number of web applications as a
  uniform solution. We trying to implement something that seems to
  be an odd requirement, evh it is really a use case for us.
 
  We would like to define a single [default] error page for all
  web applications residing on this Tomcat instance. After some
  experimentation and googling around, it seems that there is no
  clear-cut solution for
  this.
  I see a few options;
 
  - Let the global conf/web.xml define error pages for all web
  applications at once. However these are always relative to the
  web application context, and require every web application to
  pack the error pages again, which is
  a
  duplicate of resources and defeats the DRY principle.
 
  I asked a question similar to this a while back regarding JSF
  templates.
 
  If you pick a location to share this resource among all web apps,
  then your web apps aren't self contained.
 
  The solution is in your build / deploy process.

 +1

 - -chris
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1
 Comment: GPGTools - http://gpgtools.org
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

 iQIcBAEBCAAGBQJSxGvAAAoJEBzwKT+lPKRYWxsQALL6eBfL6J9Gv1Lkw1YY4sHo
 BmVEDiOW2fKpI8U7XJgWeGOJosN0Pd7hrBh4NP8KZtqP8Xx+t7yf+R0iIaftp6a9
 cN237abc629k5x8k3Cg5XwY94mVMVYRTbLu4BnlsERVCVskw+A4dhcAfwwdJRykc
 fg0FbLN0WV33uYz7zFsSl0hxP2Yhxl1ZQBocn8OgwdiEkO17K6NLZhfD54AX3W5i
 CfyXRImO6hdpHg3+XTgEQvyfP0/Ydw4n7B8XqRBN9fjOWc2hQp+SYR6Th8BrPWz1
 tRLDR07SmN3BlwSikAiiX7tibzWAfLBK5ENDJ2nUVWhAlp4A9Hbz6W+eOrHu1Bzy
 ghYVs+MMWqd0axBomKVvBq4giL1jhSB2fMno6HdLup/+FF4cdGmfK3eWM5h15rwq
 +hoXjJguZIA2riKlbn5oPKYTEpiP65ufZ5Wa2ylY5KOgQTvENYWgYNj/3p3E9gQY
 PIh9IFUjSXaeG4dZnx9ouUNGO8cBaFPYiBfTaaPyY0DRsatV96z6zCKu249GEcgM
 GZ1gumDJN0mbfsUayqGfBkhneUi83xwDItejjYxyhlxMv3bYesMxGcnmH1bN5UlC
 n/s438m6CpfvIVTq/aQH0AZqStOeVKR5uBX6nqF+yFb7IWa2XpbVonAjYjlsVMDk
 IaUOf1dAf8ISd41svgSc
 =qThL
 -END PGP SIGNATURE-

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




Re: Single error page for multiple web applications

2014-01-01 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Leo,

On 12/31/13, 3:58 PM, Leo Donahue wrote:
 On Dec 31, 2013 3:15 AM, Maarten van Hulsentop
 maar...@vanhulsentop.nl wrote:
 
 Hello,
 
 We are using Tomcat to host a number of web applications as a
 uniform solution. We trying to implement something that seems to
 be an odd requirement, evh it is really a use case for us.
 
 We would like to define a single [default] error page for all
 web applications residing on this Tomcat instance. After some
 experimentation and googling around, it seems that there is no
 clear-cut solution for
 this.
 I see a few options;
 
 - Let the global conf/web.xml define error pages for all web
 applications at once. However these are always relative to the
 web application context, and require every web application to
 pack the error pages again, which is
 a
 duplicate of resources and defeats the DRY principle.
 
 I asked a question similar to this a while back regarding JSF
 templates.
 
 If you pick a location to share this resource among all web apps,
 then your web apps aren't self contained.
 
 The solution is in your build / deploy process.

+1

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSxGvAAAoJEBzwKT+lPKRYWxsQALL6eBfL6J9Gv1Lkw1YY4sHo
BmVEDiOW2fKpI8U7XJgWeGOJosN0Pd7hrBh4NP8KZtqP8Xx+t7yf+R0iIaftp6a9
cN237abc629k5x8k3Cg5XwY94mVMVYRTbLu4BnlsERVCVskw+A4dhcAfwwdJRykc
fg0FbLN0WV33uYz7zFsSl0hxP2Yhxl1ZQBocn8OgwdiEkO17K6NLZhfD54AX3W5i
CfyXRImO6hdpHg3+XTgEQvyfP0/Ydw4n7B8XqRBN9fjOWc2hQp+SYR6Th8BrPWz1
tRLDR07SmN3BlwSikAiiX7tibzWAfLBK5ENDJ2nUVWhAlp4A9Hbz6W+eOrHu1Bzy
ghYVs+MMWqd0axBomKVvBq4giL1jhSB2fMno6HdLup/+FF4cdGmfK3eWM5h15rwq
+hoXjJguZIA2riKlbn5oPKYTEpiP65ufZ5Wa2ylY5KOgQTvENYWgYNj/3p3E9gQY
PIh9IFUjSXaeG4dZnx9ouUNGO8cBaFPYiBfTaaPyY0DRsatV96z6zCKu249GEcgM
GZ1gumDJN0mbfsUayqGfBkhneUi83xwDItejjYxyhlxMv3bYesMxGcnmH1bN5UlC
n/s438m6CpfvIVTq/aQH0AZqStOeVKR5uBX6nqF+yFb7IWa2XpbVonAjYjlsVMDk
IaUOf1dAf8ISd41svgSc
=qThL
-END PGP SIGNATURE-

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



Single error page for multiple web applications

2013-12-31 Thread Maarten van Hulsentop
Hello,

We are using Tomcat to host a number of web applications as a uniform
solution. We trying to implement something that seems to be an odd
requirement, even though it is really a use case for us.

We would like to define a single [default] error page for all web
applications residing on this Tomcat instance. After some experimentation
and googling around, it seems that there is no clear-cut solution for this.
I see a few options;

- Let the global conf/web.xml define error pages for all web applications
at once. However these are always relative to the web application context,
and require every web application to pack the error pages again, which is a
duplicate of resources and defeats the DRY principle.
- An Error reporting valve can be implemented to handle error pages. Simply
extend ErrorReportValve delivered from Tomcat and implement the report()
method. But then how should this report method behave?
1-  It could build up a HTML page from java code directly (as is being done
in the Tomcat default implementation of the ErrorReportValve). The downside
of this would be that it is not possible to style the page afterwards.
2-  It could fetch the HTML page from a location specified in configuration
(system property or otherwise) and stream it to the client. But is it
possible to have dynamic behavior in that case (jsp behavior). I think we
would need a RequestDispatcher for that and that is supposed to be in
context i presume.
3-  It could fetch the ROOT context (which has to be crossContext=true then
i assume) and delegate the handling of errors to a page in the root
context. This one would have my preference, as it allows the configuration
of a single error page, while trying to stick (mimic) as much of the normal
J2EE behavior as possible. But it also seems to be the most tricky one.
Also, i am not sure on the crossContext setting. Documentation points out
that it should not be set on security conscious environments. My experience
is that security is always important, so does this make it a no-no or is
this a theoretical security risk?

Please share your opinions about this, things i missed, or (even better!)
your solution :)

Thank you in advance!
Regards,

Maarten van Hulsentop


Re: Single error page for multiple web applications

2013-12-31 Thread Serge Fonville
Hello Maarten,

When I was in the same boat, I found
http://stackoverflow.com/questions/13914575/how-to-build-server-level-custom-error-page-in-tomcatand
http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q6 both very helpful.

I found these by googling
https://www.google.nl/?gws_rd=crei=ALNzUtHWPKKN4wTVv4DgAw#q=tomcat+webapp+error+pagesafe=off

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl


2013/12/31 Maarten van Hulsentop maar...@vanhulsentop.nl

 Hello,

 We are using Tomcat to host a number of web applications as a uniform
 solution. We trying to implement something that seems to be an odd
 requirement, even though it is really a use case for us.

 We would like to define a single [default] error page for all web
 applications residing on this Tomcat instance. After some experimentation
 and googling around, it seems that there is no clear-cut solution for this.
 I see a few options;

 - Let the global conf/web.xml define error pages for all web applications
 at once. However these are always relative to the web application context,
 and require every web application to pack the error pages again, which is a
 duplicate of resources and defeats the DRY principle.
 - An Error reporting valve can be implemented to handle error pages. Simply
 extend ErrorReportValve delivered from Tomcat and implement the report()
 method. But then how should this report method behave?
 1-  It could build up a HTML page from java code directly (as is being done
 in the Tomcat default implementation of the ErrorReportValve). The downside
 of this would be that it is not possible to style the page afterwards.
 2-  It could fetch the HTML page from a location specified in configuration
 (system property or otherwise) and stream it to the client. But is it
 possible to have dynamic behavior in that case (jsp behavior). I think we
 would need a RequestDispatcher for that and that is supposed to be in
 context i presume.
 3-  It could fetch the ROOT context (which has to be crossContext=true then
 i assume) and delegate the handling of errors to a page in the root
 context. This one would have my preference, as it allows the configuration
 of a single error page, while trying to stick (mimic) as much of the normal
 J2EE behavior as possible. But it also seems to be the most tricky one.
 Also, i am not sure on the crossContext setting. Documentation points out
 that it should not be set on security conscious environments. My experience
 is that security is always important, so does this make it a no-no or is
 this a theoretical security risk?

 Please share your opinions about this, things i missed, or (even better!)
 your solution :)

 Thank you in advance!
 Regards,

 Maarten van Hulsentop



Re: Single error page for multiple web applications

2013-12-31 Thread Maarten van Hulsentop
Hello Serge,

Thank you for your reply. This option seems to be similar to the first
thing i tried, editing conf/web.xml. As is suggested in
http://stackoverflow.com/questions/13914575/how-to-build-server-level-custom-error-page-in-tomcat

But contrary to what's stated in the stackoverlow message, this does not
work if the error occours in the context of another web application.
The following issue description is similar to mine;
http://anthonyjdev.blogspot.nl/2012/09/custom-error-page-for-all-apps-in-tomcat.html
In this case, even if the location is defined in conf/web.xml (global), the
error pages are being searched for in the context of the web application
that issued the error. In strict J2EE sense, i do understand that
reasoning. That's not what i want though ;)

If i am wrong about the understanding of all of this, please correct me.
But i just tried that stackoverlow approach again and still it seems to be
tied to the webapp that issues the error.

Thank you,

Regards,

Maarten

.





2013/12/31 Serge Fonville serge.fonvi...@gmail.com

 Hello Maarten,

 When I was in the same boat, I found

 http://stackoverflow.com/questions/13914575/how-to-build-server-level-custom-error-page-in-tomcatand
 http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q6 both very helpful.

 I found these by googling

 https://www.google.nl/?gws_rd=crei=ALNzUtHWPKKN4wTVv4DgAw#q=tomcat+webapp+error+pagesafe=off

 HTH

 Kind regards/met vriendelijke groet,

 Serge Fonville

 http://www.sergefonville.nl


 2013/12/31 Maarten van Hulsentop maar...@vanhulsentop.nl

  Hello,
 
  We are using Tomcat to host a number of web applications as a uniform
  solution. We trying to implement something that seems to be an odd
  requirement, even though it is really a use case for us.
 
  We would like to define a single [default] error page for all web
  applications residing on this Tomcat instance. After some experimentation
  and googling around, it seems that there is no clear-cut solution for
 this.
  I see a few options;
 
  - Let the global conf/web.xml define error pages for all web applications
  at once. However these are always relative to the web application
 context,
  and require every web application to pack the error pages again, which
 is a
  duplicate of resources and defeats the DRY principle.
  - An Error reporting valve can be implemented to handle error pages.
 Simply
  extend ErrorReportValve delivered from Tomcat and implement the report()
  method. But then how should this report method behave?
  1-  It could build up a HTML page from java code directly (as is being
 done
  in the Tomcat default implementation of the ErrorReportValve). The
 downside
  of this would be that it is not possible to style the page afterwards.
  2-  It could fetch the HTML page from a location specified in
 configuration
  (system property or otherwise) and stream it to the client. But is it
  possible to have dynamic behavior in that case (jsp behavior). I think we
  would need a RequestDispatcher for that and that is supposed to be in
  context i presume.
  3-  It could fetch the ROOT context (which has to be crossContext=true
 then
  i assume) and delegate the handling of errors to a page in the root
  context. This one would have my preference, as it allows the
 configuration
  of a single error page, while trying to stick (mimic) as much of the
 normal
  J2EE behavior as possible. But it also seems to be the most tricky one.
  Also, i am not sure on the crossContext setting. Documentation points out
  that it should not be set on security conscious environments. My
 experience
  is that security is always important, so does this make it a no-no or is
  this a theoretical security risk?
 
  Please share your opinions about this, things i missed, or (even better!)
  your solution :)
 
  Thank you in advance!
  Regards,
 
  Maarten van Hulsentop
 



Re: Single error page for multiple web applications

2013-12-31 Thread Leo Donahue
On Dec 31, 2013 3:15 AM, Maarten van Hulsentop maar...@vanhulsentop.nl
wrote:

 Hello,

 We are using Tomcat to host a number of web applications as a uniform
 solution. We trying to implement something that seems to be an odd
 requirement, evh it is really a use case for us.

 We would like to define a single [default] error page for all web
 applications residing on this Tomcat instance. After some experimentation
 and googling around, it seems that there is no clear-cut solution for
this.
 I see a few options;

 - Let the global conf/web.xml define error pages for all web applications
 at once. However these are always relative to the web application context,
 and require every web application to pack the error pages again, which is
a
 duplicate of resources and defeats the DRY principle.

I asked a question similar to this a while back regarding JSF templates.

If you pick a location to share this resource among all web apps, then your
web apps aren't self contained.

The solution is in your build / deploy process.

If you want to ignore that advice, Tomcat 8 now has webAppMount, if want to
go there.  I still haven't had a chance to explore that option.

Leo