All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.directwebremoting.util.DelegatingServletOutputStream Maven / Gradle / Ivy

Go to download

DWR is easy Ajax for Java. It makes it simple to call Java code directly from Javascript. It gets rid of almost all the boilerplate code between the web browser and your Java code. This version 4.0.2 works with Jakarta Servlet 4.0.2.

The newest version!
package org.directwebremoting.util;

import java.io.IOException;
import java.io.OutputStream;

import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.WriteListener;

/**
 * Delegating implementation of ServletOutputStream.
 */
public class DelegatingServletOutputStream extends ServletOutputStream {

    /**
     * Create a new DelegatingServletOutputStream.
     * @param proxy the target OutputStream
     */
    public DelegatingServletOutputStream(OutputStream proxy)
    {
        this.proxy = proxy;
    }

    /**
     * Accessor for the stream that we are proxying to
     * @return The stream we proxy to
     */
    public OutputStream getTargetStream()
    {
        return proxy;
    }

    @Override public void write(int b) throws IOException {proxy.write(b);}

    @Override public void flush() throws IOException {
        super.flush();
        proxy.flush();
    }

    @Override public void close() throws IOException {
        super.close();
        proxy.close();
    }

    private final OutputStream proxy;

    /** @return true */
    @Override public boolean isReady() {return true;}

    /** Does nothing. */
    @Override public void setWriteListener(WriteListener writeListener) {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy