Can we have a filter to handle all the apps in a container?

Hi,
I have a simple (Stupid) question.
Can I configure a Servlet filter to intercept requests to all the applications (a.k.a all the ServletContexts)? All I know is we can configure a filter for each ServletContext (application), but I am wondering if there is any way.
The reason I am asking is because, if there is a way to do so, I can configure my filter to provide me the debug output (Such as CGI, session, request, and ServletContext variables) on all the applications on development servers and when I can get rid of debugging on production servers (by not deploying the filter).
Thanx in advance,
Thirupati Panyala

Thanks for the reply Sudhir.
I tried it in Tomcat 4.x. It works for only the root resources even though I configured the filter for /* which is expected to include all the resources including root (for ex: /examples/...).
So, I understand, the web.xml under /conf will be overriden by that of the respective apps as you go further down the context paths (apps). That's why the container was not executing my filter when I went to the next level of the URI (http://localhost:8080/index.html WORKED, but NOT http://localhost:8080/examples/jsp/num/numguess.jsp).
If you want to try it for yourself, here is the piece of code I tried with (This is taken from Apache Tomcat source):
package filters;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.util.Enumeration;
import java.util.Locale;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
* Example filter that dumps interesting state information about a request
* to the associated servlet context log file, before allowing the servlet
* to process the request in the usual way. This can be installed as needed
* to assist in debugging problems.
* @author Craig McClanahan
* @version $Revision: 1.5 $ $Date: 2001/05/23 22:26:17 $
public final class RequestDumperFilter implements Filter {
// ----------------------------------------------------- Instance Variables
* The filter configuration object we are associated with. If this value
* is null, this filter instance is not currently configured.
private FilterConfig filterConfig = null;
// --------------------------------------------------------- Public Methods
* Take this filter out of service.
public void destroy() {
this.filterConfig = null;
* Time the processing that is performed by all subsequent filters in the
* current filter stack, including the ultimately invoked servlet.
* @param request The servlet request we are processing
* @param result The servlet response we are creating
* @param chain The filter chain we are processing
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
     throws IOException, ServletException {
if (filterConfig == null)
     return;
     // Render the generic servlet request properties
     StringWriter sw = new StringWriter();
     PrintWriter writer = new PrintWriter(sw);
     writer.println("Request Received at " +
          (new Timestamp(System.currentTimeMillis())));
     writer.println(" characterEncoding=" + request.getCharacterEncoding());
     writer.println(" contentLength=" + request.getContentLength());
     writer.println(" contentType=" + request.getContentType());
     writer.println(" locale=" + request.getLocale());
     writer.print(" locales=");
     Enumeration locales = request.getLocales();
     boolean first = true;
     while (locales.hasMoreElements()) {
     Locale locale = (Locale) locales.nextElement();
     if (first)
     first = false;
     else
     writer.print(", ");
     writer.print(locale.toString());
     writer.println();
     Enumeration names = request.getParameterNames();
     while (names.hasMoreElements()) {
     String name = (String) names.nextElement();
     writer.print(" parameter=" + name + "=");
     String values[] = request.getParameterValues(name);
     for (int i = 0; i < values.length; i++) {
     if (i > 0)
          writer.print(", ");
          writer.print(values);
     writer.println();
     writer.println(" protocol=" + request.getProtocol());
     writer.println(" remoteAddr=" + request.getRemoteAddr());
     writer.println(" remoteHost=" + request.getRemoteHost());
     writer.println(" scheme=" + request.getScheme());
     writer.println(" serverName=" + request.getServerName());
     writer.println(" serverPort=" + request.getServerPort());
     writer.println(" isSecure=" + request.isSecure());
     // Render the HTTP servlet request properties
     if (request instanceof HttpServletRequest) {
     writer.println("---------------------------------------------");
     HttpServletRequest hrequest = (HttpServletRequest) request;
     writer.println(" contextPath=" + hrequest.getContextPath());
     Cookie cookies[] = hrequest.getCookies();
if (cookies == null)
cookies = new Cookie[0];
     for (int i = 0; i < cookies.length; i++) {
     writer.println(" cookie=" + cookies[i].getName() +
               "=" + cookies[i].getValue());
     names = hrequest.getHeaderNames();
     while (names.hasMoreElements()) {
     String name = (String) names.nextElement();
          String value = hrequest.getHeader(name);
     writer.println(" header=" + name + "=" + value);
     writer.println(" method=" + hrequest.getMethod());
     writer.println(" pathInfo=" + hrequest.getPathInfo());
     writer.println(" queryString=" + hrequest.getQueryString());
     writer.println(" remoteUser=" + hrequest.getRemoteUser());
     writer.println("requestedSessionId=" +
               hrequest.getRequestedSessionId());
     writer.println(" requestURI=" + hrequest.getRequestURI());
     writer.println(" servletPath=" + hrequest.getServletPath());
     writer.println("=============================================");
     // Log the resulting string
     writer.flush();
     response.getWriter().print(sw.getBuffer().toString());
     // Pass control on to the next filter
chain.doFilter(request, response);
* Place this filter into service.
* @param filterConfig The filter configuration object
public void init(FilterConfig filterConfig) throws ServletException {
     this.filterConfig = filterConfig;
* Return a String representation of this object.
public String toString() {
     if (filterConfig == null)
     return ("RequestDumperFilter()");
     StringBuffer sb = new StringBuffer("RequestDumperFilter(");
     sb.append(filterConfig);
     sb.append(")");
     return (sb.toString());
And the config in web.xml is :
<filter>
<filter-name>Request Dumper Filter</filter-name>
<filter-class>filters.RequestDumperFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Request Dumper Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Thanx
Thirupati Panyala

Similar Messages

  • Can I Hav a chance to download all paid apps for free

    Can I Hav a chance to download all paid apps for free

    Uh, no. There's no, uh, "legal" way <edited by host> to get any paid apps for free, unless the devs choose to make that app free for a day.
    You could find an app, like FreeAppaDay which will ask some devs to make an app free for a day, and you can check the FAAD app to see what apps are free.

  • HT4623 i need to get one of my older iphones (my wifes) assing to me in my name . Can i do this with out loosing all the apps and contacts on it?

    i need to get one of my older iphones (my wifes) assing to me in my name . Can i do this with out loosing all the apps and contacts on it?

    Use your backup copy of your old computer to put everything on your new computer, then sync the iphone to that comptuer.

  • HT1420 I just bought my cousin's ipod, and I want to update it on my computer.  However, it needs authorization from his account to keep all the apps, and he's already authorized it on 5 computers.  How can I update this ipod without losing all the apps?

    I just bought my cousin's ipod, and I want to update it on my computer.  However, it needs authorization from his account to keep all the apps, and he's already authorized it on 5 computers.  How can I update this ipod without losing all the apps?

    You cannot use someone else's apps without violating the license agreement. The apps are tied to the owner (via Apple ID). The right thing to do would be to update and start fresh.

  • I have my iPad2 setup with all the apps working nicely on iOS 5.

    Is there a way to disable updates to all my apps and to iOS 6?

    Hi
    Update the applications thru App Store

  • I have an old 4GB Ipod nano and an I-Phone 4S. I only want music to sync to my I-Pod without all the apps from the phone. Can someone tell me how to do this please?

    I'm updating the music in my I-Tunes. I have an old 4GB Nano but I also have an I-Phone 4S. I only want music and nothin else on my I-Pod, how can I get it to sync without all the apps as, obviously the I-pod doesn't have enough memory?

    "Other" is data that the iPod doesn't know how to deal with (but on your nano, it isn't Apps). All iPods have some quantity of "Other" on them. Sometimes Other is corrupt files that cannot be read.
    The usual remedy when the quantity of Other becomes too big, is to Restore the iPod. However, 0.26GB of Other doesn't appear to be very much and I suspect you won't see much change, if any, if you Restore.

  • How can I get the Airport Express to handle all the PPPoE stuff?

    Hi, I’m visiting my family in China, and now trying to help my dad, with his Airport Express and how to set up a PPPoE connection.
    We have currently set up the Airport Express in bridge mode (not distributing IP adresses and selecting DHCP under the Internet tab in admin utility). The Airport settings on our two computers is set up to connect using PPPoE using the given login name and password. (ps! we can not see the Base station in Airport Admin Utility when using these settings, we would have to select a new location from the Apple menu to see it and make condigurations.)
    What we want is to do, is to have the Airport Express connect to the ISP using a PPPoE connection and not through the computer.
    I know there is a 'Connect using PPPoE' option in Airport admin util, letting me input account name and password. If I select this setting instead of DHCP, enable distribution of IP addresses and configure my Airport card to NOT connect using PPPoE, I will see my base station in the Airport admin util with the IP address of 10.0.1.1 (or similar) and my computer will have x.x.x.2. Next to the Airport icon in the menubar, a scrolling message will say 'Looking for PPPoE host' without anything happen. I am sure my account name and password is correct as they've both worked when using this computer to connect to PPPoE (like now)
    How can I get the Airport Express to handle all the PPPoE stuff without using bridge mode?
    Ps! Both me and my dad have iPhones whom we can’t seem to get to connect unless its been distributed an IP address cause there's as fars as I know, no options of inputing a PPPoE user name and password.

    Any solutions to this? I'm in China also, in Beijing, trying to get my Airport Express to work with an ADSL modem.
    Direct ethernet cable connection to my Macbook works fine.
    When I configure the Airport Express with the ID and password that seems to be fine also – Airport Express shows a green light.
    But I cannot figure out the settings to connect wirelessly from my Macbook to the Airport Express. I get a constantly scolling message: "Looking for PPPoEhost..."
    thanks
    Paul

  • Can anyone recommend a duplicate file finder application for OS10.6 systems?  All the apps I find on the App Store are only for 10.7 and later.  I don't know how to filter a search by operating system (if this is even possible).

    Can anyone recommend a duplicate file finder application for OS10.6 systems?  All the apps I find on the App Store are only for 10.7 and later.  I don't know how to filter a search on the App Store by operating system (if this is even possible).  I currently have a MacBook running OS10.6.8.   If you can recommend an app,  please post the URL.     Would appreciate any helpful suggestions....  
    <Email Edited By Host>

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • HT204053 can you have multiple apple id's for the family but we all use the same iCloud?

    Can you have multiple apple id's for the family members but we all us the same iCloud account?

    You'll have to have an ID you all share in order to have a shared iCloud account. It would be sensible for each person to have their own ID and their own iCloud account for email and their own data (each would be on their own computer/iOS device or user account on a Mac) and then have a common account which everyone would sign into in System Preferences>Mail, Contacts and Calendars to access shared data.
    You don't want to be all using the email in a common account - if people are using email aliases remember these can't be detached from the account and transferred to another one. Having all your emails mixed up together can be somewhat impracticable.

  • Hi, I don't know who to turn to: the person who handles all the compter stuff is out of town, This A.M.I started up Firefox and there was a message re an update, I thoght I new just to click on install and wait to re start Firefox. But what I can remember

    Hi, I don't know who to turn to: the person who handles all the compter stuff is out of town, This A.M.I started up Firefox and there was a message re an update, I thoght I new just to click on install and wait to re start Firefox. But what I can remember is that another window opened and asked me to choose 'something' (an icon or banner or?), I thought I must click something (I guess I should read all clearly). Firefox did update to 3.6.4, but it also inserted some sort of what might be called a banner? But it only partly covers the right one- half of my 3 toolbars at the top of the Firefox window. It can't be used for anything as it is just a mess of colors and unknowns, except what looks like a 'top' and what I recognize as a Firefox icon (but only partly visible)!! Now, what it does do is partly hide that whole portion of the toolbars and they are hard to read and in turn make this 'thing' impossible to figure out, if I would care to? I can't find anyway to remove it or use it?? But since the Firefox icon is on it, I guess you should know what it is and how to trash it. I am sorry for this occurrence caused my my carelessness, but I'm not much of a computer person ----HELP! Thank you for any help. Judi
    == This happened ==
    Every time Firefox opened
    == Today, Thrsday June 24, 2010

    The only thing I can imagine: it's a [https://addons.mozilla.org/en-US/firefox/personas/ Persona].
    Tools->Add-ons->Themes
    Here should be the persona (lightweight theme)
    and a button "Remove"
    Click it (button Remove), and it (Persona, this mix of colors) should go away instantly.
    Does it help you?

  • I can't open my iPod library in iTunes, the app doesn't show the device at all, no error message, nothing, but windows 8 opens it like it would a flash drive. It has worked for me before just fine and both have the most updated software versions.

    I can't open my iPod library in iTunes, the app doesn't show the device at all, no error message, nothing, but windows 8 opens it like it would a flash drive. It has worked for me before just fine and both have the most updated software versions. HELP PLEASE!

    yeah i plugged in my iphone to my computer and itunes does not even notice that i plugged it in.

  • I have two apple accounts, but can only access one. I did all the steps to recover the older account's password but nothing worked. I need to access the older account to update apps. Also would there be a way to just combine both accounts?

    I have two apple accounts, but can only access one. I did all the steps to recover the older account's password but nothing worked. I need to access the older account to update apps. Also would there be a way to just combine both accounts?

    Were you able to reset the account's password ? If not then how did you try to get it reset e.g. http://iforgot.apple.com (which would have sent it to the rescue email address if you have one on that account) ? You can also try contacting iTunes Support in your country to get it reset : http://support.apple.com/kb/HT5699
    And no, accounts can't be merged nor content transferred between accounts.

  • Help - I have an apple id account, where is my iPod and iPad registered, but also the iPod of my daughter. How can I make an account for my daughter and keep all the apps she has on her iPod?

    Help - I have an apple id account, where is my iPod and iPad registered, but also the iPod of my daughter. How can I make an account for my daughter and keep all the apps she has on her iPod and in her own iTunes?

    Sorry, content bought with one Apple ID cannot be merged or transferred to another Apple ID.

  • Everytime I try to update to iOS5 on my iPhone 4 I get an error containing 0xE while it is trying to backup data from the iPhone.  I have done everything suggested in Apple support.  How can I upgrade to iOS5 without losing all the data on my phone?

    Everytime I try to update to iOS5 on my iPhone 4 I get an error containing 0xE while it is backing up data from the iPhone before installing the new operating system.  I have done everything suggested in Apple support with no success.  I still get the error everytime (about 5 minutes into backing up iPhone data).  How can I upgrade to iOS5 without losing all the data on my iPhone (the error message says that if I continue I will lose all data on the phone)?  If I have already synced the phone before upgrading the OS, would I be able to restore my data after installing the new OS by syncing after the OS upgrade is complete?  Any help would be greatly appreciated. 

    I had the same problem today and was able to resolve it without having to do a restore or reset. The problem had something to do with my mail accounts. The upgrade reset my mail settings, switching both my gmail and my .mac mail to "archive all mail". I went into the General Settings, disabled that setting, and resynced the phone. The "other" storage allottment dropped back down to less than a gig.
    Before you restore or reset, I would try that first.

  • I have my boyfriend's apple ID and password, how do I check what apps he has on his phone? ( not all the apps that he had downloaded, but the ones that are actually on his phone). And How can I remotely download apps to his phone if I have his ID

    I have my boyfriend's apple ID and password, how do I check what apps he has on his phone? ( not all the apps that he had downloaded, but the ones that are actually on his phone). And How can I remotely download apps to his phone if I have his ID and PW?
    Thank you so much

    If you want seperate accounts for managing apps and purchasing content, basically yes, you need two account and would need to repurchase. However, if you just want seperate ID for iMessgae, icloud and such, you can do that and still continue sharing the same Id for apps and itunes.

Maybe you are looking for