tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Tomcat Wiki] Update of "HowTo" by KonstantinKolinko
Date Sat, 02 Feb 2013 22:42:43 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.

The "HowTo" page has been changed by KonstantinKolinko:

Add a warning. There should be a better recipe somewhere in the mailing list archives.

  Context context = (Context) host.findChild("myContext");
  Realm realm = context.getRealm();
+ '''Warning:''' The above recipe on how to obtain a `Context` for a web application is a
bit obsolete and does not work in Tomcat 7 and later (as Server is no longer a singleton).
There are other ways to achieve that. An easy one is to add a `Valve` or `Listener` to a context,
as those classes have access to Tomcat internals. There may be other ways mentioned in the
archives of the [[FAQ/Tomcat_User|users mailing list]].
  == How do I redirect System.out and System.err to my web page? ==
  I have met a situation where I needed to redirect a portion of standard ouput (`System.out`,
STDOUT) and standard error (`System.err`, STDERR) to my web page instead of a log file. An
example of such an application is a compiler research platform that our resarch team is putting
online for anybody to be able to quickly compile-test their programs on line. Naturally, the
compilers dump some of their stuff to STDERR or STDOUT and they are not web application `.jar`.
Thus, I needed badly these streams related to the compiler output to be redirected to my web
editor interface. Having found no easy instructions on how to do that lead me writing up this
quick HOWTO. The HOWTO is based on Servlets, but similar arrangements can be done for JSPs.
The below example shows the essentials, with most non-essentials removed.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message