PrintWriter Solution to Flushing (seems like a hack tho)

All,
I have been trying to write a XSS filter. The filtering was the easy part. For some reason, when I overload getWriter() in HttpServletResponseWrapper and return my own writer, the final buffer is not being flushed.
Here is what I have experienced. The following line of code was my first attempt:
return new PrintWriter(new XssPreventOutputStream(out));Nada. When I place debug statements in my output stream (which extends ServletOutputStream), the final buffer is never even passed to write(byte[], int, int). So, I extended PrintWriter and overloaded the following:
public void write(char[] buffer, int offset, int length) {
   super.write(buffer, offset, length);
   super.flush();  // Why do I have to do this?  This is what smells funny to me
}Placing an additional call to flush() in close() does nothing. I seem to have to flush() on every write(char[], int, int) in my overloaded PrintWriter. Am I doing something wrong? BTW, the custom output stream I wrote does nothing (yet):
public final void write(final byte[] buffer, final int offset, final int length)
          throws IOException {
          System.err.println("DEBUG >>> write(byte[] int, int) : \r\n" + new String(buffer, offset, length));
          out.write(buffer, offset, length);
     }I'm sure there is something so obviously simple it is completely escaping me right now. I just feel that issuing flush() after every write(char[], int, int) is a hack.
Thanks!
- Saish

Thanks for the replies. If I overload close() and place debugging statements in there, it is being called. I am overloading the PrintWriter returned by ServletResponse#getPrintWriter(). So, I do not really have explicit control (nor do I think I should) when Struts is being used.
Another oddity, not sure if it will help, but I do see debugging messages that flush() is also being called, to no effect unless I place the flush in write(char[], int, int), which to me seems like a mistake. (Sorry if this is too vague).
- Saish

Similar Messages

  • Seems like someone hacked my account

    There are playlist and songs I haven't played. Sometimes my music is stopped and other music begins. There were some other devices that were on my account which I deleted, but they are still accessing my account. It's annoying but I worry even more about billing information. Any ideas? I can't seem to find a way to contact Spotify about this.

    Hello  & welcome to the Community!
    You can follow these steps in order to ensure nobody is accesing your account:
    Enter your account settings, scroll all the way to the bottom and click "Sign Out Everywhere".
    Then proceed to change your accounts password.
    This should stop any undesired people using your account.
    Hope this helps! ♫
     

  • Can't import favorites. Seems like IE closes FF when I try.

    I am following the instructions given to import my fav's from IE but when I get to the last part it stops and I get a window that says FF has shut down and Windows will let me know when the problem has a solution. Almost seems like it doesn't want me using this.

    Make sure that you do not run Firefox in permanent Private Browsing mode.
    *https://support.mozilla.com/kb/Private+Browsing
    You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    *Deselect: [ ] "Always use private browsing mode"

  • TS4062 My Iphone won't appear in my devices in Itune.... And the WiFi does not work on my phone.... I seems like there is no solution to update my phone to the new ios on my computer or WiFi without using the 3g because of this!!! help me out

    My Iphone won't appear in my devices in Itune.... And the WiFi does not work on my phone.... I seems like there is no solution to update my phone to the new ios on my computer or WiFi without using the 3g because of this!!! help me out

    Hello there, TempestBelcher.
    It seems you've covered all the bases, but feel free to review the iPhone Troubleshooting Assistant for connectivity here:
    Apple - Support - iPhone - Calls Troubleshooting Assistant
    http://www.apple.com/support/iphone/assistant/calls/#section_0
    If you've followed all the instructions then there are a few good recommendations for what to do next in the last step.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

  • Possible security problem with my iPhone4, it seems like it has been hacked into and my hotmail, facebook and university accounts (which all have different passwords) and proceed to change my passwords on me. This has happened twice.

    I seem to be having security problems with my iPhone4, it seems like someone has hacked into my hotmail, facebook and university accounts (which all have different passwords) and proceed to change my passwords on me. This has happened twice and I have not left my phone unattended at any time that I can recall nor have I accessed these accounts from another source (i.e. computer/laptop) since changing my passwords after the first hacking occurred. Please help.

    Anyone else at your university complaining about the same thing?  It is more likely someone is stealing passwords by sniffing traffic over the university wifi or with a man-in-the-middle attack or by other means external to your phone.  Try a Google search on "steal password" (without quotes) or "steal SSL password" and you'll learn more than you wanted to know about how passwords get stolen.
    Some related info:
    http://en.wikipedia.org/wiki/Session_hijacking
    http://en.wikipedia.org/wiki/Man-in-the-middle_attack

  • My iphoto won't open. it seems like it's charging pictures but it's not working

    hello goodmornig,
    i'm writing because i need help with my iphoto. it got stucked. seem like it's charging the pictures but it just won't work.
    i can't see my pictures.
    i would like to know what's going on!
    please help!

    With the amount of information you've provided it's impossible to offer a potential solution.  We can't see your computer so we need to know the details of your problem and setup, i.e.:
    what version of iPhoto are you using?
    what system version are you running?
    what fixes have you tried?
    where is your library located?
    did you apply any updates or upgrades just prior to the problem occurring?
    are you running a "managed" or "referenced" library?
    what type of Mac?
    how much free space on your boot drive?
    OT

  • "It seems like Adobe Air is not installed. Please install it!" Error during Plugin Installation

    Hello
    I get this Error Message after I tried to install "typeDNA" latest Version 2.2.0:
    "It seems like Adobe Air is not installed. Please install it!"
    If I press OK Button "Setup" says:
    "Runtime Error (at 17:233):
    Runtime Error (at 1:46):
    Internal Error: An Attempt was made to expand the "app" constant before it was initialized"
    Befor that I updated Adobe AIR to latest Version (3?) with no Problems.
    Log:
    [2011-11-04:02:19:36] Runtime Installer begin with version 3.0.0.4080 on Windows 7 x86
    [2011-11-04:02:19:36] Commandline is:
    [2011-11-04:02:19:36] No installed runtime detected
    [2011-11-04:02:19:39] Relaunching with elevation
    [2011-11-04:02:19:39] Launching subprocess with commandline c:\users\julian~1\appdata\local\temp\air1ff0.tmp\adobe air installer.exe -ei
    [2011-11-04:02:19:42] Runtime Installer begin with version 3.0.0.4080 on Windows 7 x86
    [2011-11-04:02:19:42] Commandline is: -stdio \\.\pipe\AIR_1984_0 -ei
    [2011-11-04:02:19:42] No installed runtime detected
    [2011-11-04:02:19:42] Starting silent runtime install. Installing runtime version 3.0.0.4080
    [2011-11-04:02:19:42] Installing msi at c:\users\julian~1\appdata\local\temp\air1ff0.tmp\setup.msi with guid {ACEB2BAF-96DF-48FD-ADD5-43842D4C443D}
    [2011-11-04:02:19:42] Runtime Installer end with exit code 0
    [2011-11-04:02:19:43] Elevated install completed
    [2011-11-04:02:19:46] Launching subprocess with commandline c:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater -installupdatecheck
    [2011-11-04:02:19:46] Runtime Installer end with exit code 0
    [2011-11-04:02:19:46] Runtime Installer begin with version 3.0.0.4080 on Windows 7 x86
    [2011-11-04:02:19:46] Commandline is: -installupdatecheck
    [2011-11-04:02:19:46] Installed runtime (3.0.0.4080) located at c:\Program Files (x86)\Common Files\Adobe AIR
    [2011-11-04:02:19:47] Performing pingback request
    [2011-11-04:02:19:47] Starting runtime background update check
    [2011-11-04:02:19:47] Begin Background update download from http://airdownload.adobe.com/air/3/background/windows/x86/patch/3.0.0.4080/update
    [2011-11-04:02:19:47] Unpackaging http://airdownload.adobe.com/air/3/background/windows/x86/patch/3.0.0.4080/update to C:\Users\Julian Friedrich\AppData\Roaming\Adobe\AIR\Updater\Background
    [2011-11-04:02:19:47] Runtime update not available
    [2011-11-04:02:19:47] Unpackaging cancelled
    [2011-11-04:02:19:47] Runtime Installer end with exit code 0
    After unsintall and Installation same thing. thx for youre help.

    No Solutions? =(

  • Strange behaviour in IMAP-Mode, seems like POP3

    Hi all,
    yesterday my new E61 arrived from amazon. Nice gadget but I really need a working solution for my email.
    I have set up an IMAP-account (web.de pay in Germany). Now I sometimes receive the mails much later than on my computer (interval is 5 minutes). I do not receive all mails on both devices: Some only appear on my computer, others appear only on the E61. It seems like it fetches some mails (like POP does) but it really is set to IMAP4. So sometimes mails only appear on the E61 and not on my computer. Mails sent via E61 do not appear in my computers "sent mails" bin. Mails deleted on the E61 do not get deleted on my computer (I did the setting for that on the E61).
    I still have the April firmware but it is annoying not to be able to use it as a proper email solution right from the start.
    What can I do to fix the issue (IMAP)?
    Thank you

    first off, i would confirm your email provider supports this device.
    after that, i would then enquire as to how the server handles your emails.
    also, how do you connect? wlan or 3g? it could be an issue with your connection...

  • While charging Display screen becomes blank, Seems like crash

    Hi,
    I have Pavilion dv5z - 1200 series laptop. Few months back, I changed my laptop batteries. But recently, I started facing problem of blacking out display when I start charging. It just does not display anything seems like OS crashes.
    Any information is appreciated.
    Thank you,
    VK2011

    have you done a hard boot...
    remove the battery, other peripherals and the AC adapter... press and hold the power button for 20 seconds... plug the AC adapter only and turn on the notebook....
    ||-Although I am working on behalf of HP, I am speaking for myself and not for HP.-||
    //Click on Kudos if my reply was helpful and answered your question//
    ||-If my answer solved the problem please mark the topic as the accepted solution-||

  • I just purchased iPhone 5S and I am unable to record my custom greeting.  It seems like it is recording but when I play it cuts off after "hello"

    I just purchased iPhone 5S and I am unable to record my custom greeting.  It seems like it is recording but when I tried to play it back it just plays "hello" and that is it.

    Hacking an iPhone is against's Apple license agreement for the iPhone and is not supported by Apple directly or indirectly via these discussions not to mention removes the built-in security included with iOS and has likely bricked your iPhone now.
    Contact whoever you downloaded that hacking garbage from for help with this.

  • On doing a full Restore on my iMac from A time capsule, I am getting a permanent white apple screen with permanent loading wheel. This is my second attempt to restore with the same outcome. Seems like the last stage of the restore is getting stuck. Any ti

    On doing a full Restore on my iMac from A time capsule, I am getting a permanent white apple screen with permanent loading wheel. This is my second attempt to restore with the same outcome. Seems like the last stage of the restore is getting stuck. Any tips on how to sort this out please.
    iMac, Mac OS X (10.7.3)

    It just means some spammer is using your email address as the sender address for their spam. This is very easy to do - anyone can do it simply by changing the From email address in their email program. It does not mean your account was hacked or you have a virus (there are no current Mac viruses on the loose anyway, nor has there been for years).
    There's nothing you can do about it. It can happen to anyone and the spammers will move on to using someone else's email address before long.

  • I created a form, I want the email notices to go to several people. Why is this so difficult? It seems like they have to be a co-author/reader or something? I don't get it

    I created a form, I want the email notices to go to several people. Why is this so difficult? It seems like they have to be a co-author/reader or something? I don't get it

    This is crazy! I paid for this service to make it easier to create forms for a company that has had several acquisitions all over the globe. This was supposed to make it easy to create forms hosted on adobe so no matter what happens on all their servers, we would be safe using this forms service until we can integrate all acquisitions and build a permanent web site on a single server. Now I find out that even this is a major issue sending emails to team members, many I have never met so making them a collaborator or even setting up forwarded emails is not something I wanted to do. This service was advertised as simple and easily send notifications to many people. I am now frustrated and thinking this was a waste of money! Why is it like that?

  • Why does the new operating system not delete the moved files from their original location - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it

    Why does the new operating system not delete the moved files from their original locations - it seems like an enormous waste of space, time and effort to clean up every file once you've moved it - also, when transferring large amounts of files it becomes a very large problem remembering which files were transferred and which not.

    You're going to need to be more specific, as I'm not quite sure I understand what you're talking about.
    If you're referring to copying from an external hard drive or flash drive, and you want to actually move files rather than copy them, you can hold down the option key to force it to do a "move" rather than a "copy." This is not new behavior, though... the Mac OS has worked this way as long as I can recall (and I've been using it since 1984).
    If you're having a problem with trying to move files from one place to another on a single drive causing them to be copied instead, that is likely because of some permissions issue preventing you from actually being able to move them.

  • How to print a selection of pages from a 3000   page PDF without having to scroll two wheels! Also is there a way to set printer options for just black and white? Seems like there is a lot missing here?

    I have been using this for school work as much as possible and have come across a problem. With my lack of knowledge for apple it seems as though I can't navigate myself to a easy answer. The problem hits when I am printing pages off of a large document, and I don't want to print the entire document in color but I have no way "that I can find" for a black and white print option...
    ----- also a larger issue, when printing I need to select 1 page or even 20 pages... The time it takes to use a scroll wheel and the fact if you try and scroll fast sometimes you click off the screen then you have to start scrolling all over again... It seems like you would beagle to input from say page 1224 to 1236.... Instead I have a scroll a wheel? Just doesn't make sense...?
       Can someone please help solve this for me!

    Yes, that fixed it, thanks! I had no idea they clashed like that. I ruthlessly purged all other tables of contents, and then used Layout > Table of Contents to create a new one, and it worked.
    It made more sense after seeing in this thread that table of contents styles are more like presets or entities than styles.

  • I've just bought an iPhone 5S in the UK, seems like a big mistake. I have turned off sync to icloud from the phone for both my contacts and calendar, as told on itunes. However, iTunes still says they are synced from iCloud and wont sync to PC, Fix ?

    I've just bought an iPhone 5S in the UK, seems like a big mistake, but luckily by law we can return goods, which is exactly what is going to happen if I cant get this to work. This is my business phone, not having it functional can cost me money.
    I have turned off sync to icloud from the phone for both my contacts and calendar, as told on itunes. However, iTunes still says they are synced from iCloud and wont sync to my PC, why and how do I fix it so that it doesnt go to iCloud for anything ?
    The phone currently has no contacts or calendar information installed.
    PC is HP Probook 4730s running Windows 7, Professional, version 6.1.7601 Service Pack 1 Build 7601.

    I'm happy you figured it out and just try to keep in mind that not everyone you talk to at support will give the same advice or have the same knowledge. Just like those who contribute to these forums. Sometimes Google is your best friend.
    I agree that Apple could probably make it easier, but as of yet prefer security over freedom. (sound famaliar?)
    Anyway, if you choose to do so, you can leave feedback here:
    Apple.com Feedback
    Apple Support Feedback
    Developer Feedback
    Product Feedback
    QuickTime Feedback
    Search Feedback

Maybe you are looking for