How to use Filter/Responsewrapper to trap http response

My application deals with various request/responses. How do i write a Responsewrapper or responseoutputstream to trap the contents of the response in a file without fiddling with the actual servletoutputstream, which is thrown back to the browser as usual.

Thanks for the answers,
I am using something like this in my filter code
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CacheResponseWrapper wrappedResponse = new CacheResponseWrapper(hres, baos);
chain.doFilter(hreq, wrappedResponse);
FileOutputStream fos = new FileOutputStream(file);
fos.write(baos.toByteArray());
fos.flush();
fos.close();
FileInputStream fis = new FileInputStream(ile);
String mt = sc.getMimeType(hreq.getRequestURI());
response.setContentType(mt);
ServletOutputStream sos = hres.getOutputStream();
for (int i = fis.read(); i!= -1; i = fis.read()) {
     sos.write((byte)i);
The CacheResponseWrapper uses a CacheResponseStream which write the necessary bytes to the provided ByteArrayOutputStream instead of the general ServletOutputStream

Similar Messages

  • How to  use  Filter  in ActionServlet

    hi how do i use filter in my ActionServlet ?
    here is a code :
    package test;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    public class TimeFilter implements Filter {
      public void init(FilterConfig config) throws ServletException {
      public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        // only service the request between 08:00 and 17:59
        if (hour >= 8 && hour <= 17) {
          chain.doFilter(request, response);
        // for other times, forward the request to someplaceelse
        } else {
          request.getRequestDispatcher("/someplaceelse").forward(request, response);
      public void destroy() {
    }where do i place it in my ActionServlet to get filtered access ?
    My ActionServlet :
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    import java.io.*;
    import java.util.*;
    public final class SubmitAction extends Action {
      public ActionForward perform(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) {
          DynaActionForm SubmitForm = (DynaActionForm) form;
         // blah
        // blah
    return (mapping.findForward("success"));
    }can ActionServlet use filter ?
    How do i use the Filter class in ActionServlet if i want to get filtered Aceess of the website ?

    Ok, this is how filters work.
    Typically the filter maps to '/*' and your action servlet maps to '/*.do'. So if you request 'login.do', then the filter would first be called. If it's not between 08:00 and 16:59, the request will be passed on to the action servlet, else it would be forwarded to the action servlet.
    There's no need to 'integrate' the filter into you action servlet.

  • How to use filter for data tables? Important topic but no docs/examples.

    I was looking at the TableRowGroup APIs:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/docs/apis/webui/index.html
    and looks like it has getTableDataFilter and setTableDataFilter methods. Sounds to me, that we can use TableDataFilter to filter rows that are displayed. For example, we can provide users with a drop down list of fields to choose from, and input field to enter the value of the selected field, so that they can narrow down the rows to search for specifics row(s) they are looking for.
    I have not seen any example, or enough documentation, to figure out how to use this filter. Since JSC is new, there are not too many resources out there or on web for such specific issues. Any gurus out there?
    Thanks

    Creator Team: Data filtering tutorial is over due now. This is something that will be useful to most developers. We all want to display users some data and want to provide user ability to filter it down based on some criteria, i.e. display rows within a date range, display all rows that have certain value or a field, etc. If there is a built-in filter in TableRowGroup, why not document it adequately along with some examples and a tutorial?
    This is one of the key elements of Microsoft/VS.NET market share -- provide tons of example/tutorials/advanced code/books/3rd party books, etc. Why can't other companies follow a well-proven success element? In spite of making a better product, the can end up loosing or not gaining enough share, because of this lack of attention.

  • How to use FILTER -- USING    in rpd???

    Can we use FILTER USING in rpd ?

    Yes in the 'use existing logical columns as the source' window of a measure.
    Its under Functions - Display Functions in the expression builder.

  • How it use Filter Id and FilterPanelFocusid in JSF Table component

    How it use FilterId and FilterPanelFocusid in JSF Table component

    How it use FilterId and FilterPanelFocusid in JSF Table component

  • How to use Htm5 banner rotator and jqury responsive manue

    just purchased and installed HTML5 Banner Rotator and Jquery Responsive manu.  I need help or video tutorials on how to use these add-on in my dreamweave cc 2014 website. eg how do I adjust it to fit in my site

    Check with the developer's documents for your addons/extensions.  Failing that, we would need you to upload your test page and dependent files to a public web space you control and post the URL here so we can take a look at it.  Anything less is all guesswork.
    Nancy O.

  • How to use filter to color cell content

    Numbers 3.5.2: I would like the content of a cell to change color, if the value of the number within the cell drops down below a certain value. For instance: as long as the values in the cell stay above 50 -> the number should be displayed black, if below 50 -> number should appear in red.
    This was possible in Numbers 09 using a simple filter as shown here:
    Did this filter disappear in actual Numbers? Is there any alternative?
    Thanks
    Ulrich

    What you are looking for isn't a "filter", its conditional text or conditional highlighting: http://help.apple.com/numbers/mac/3.5/#/tan93f5de5c3

  • MDX : How to use filter on a dimension without showing it OR merge 2 attributes of the same dimension?

    Hello everyone,
    I'm kind of newbie with MDX language, I'm trying to get filtered measures from a cube with a specific layout.
    Here is my exemple :
    I want to get all the "order numbers" where the "invoice" cost is more than 300.  Each invoice is linked with an ID, one order number can have several invoices.
    So what I do is a select request with 2 dimensions : "order num" and "id_invoice"
    Here is the result : I get all the cost sorted by "order num" and I can easealy identify those who are above 300
    order num
    Id_invoice
    cost
    Total
    Total2
    15450307
    10032013094498
    1671
    1737
    ok
    15450307
    10032013099835
    66
    1737
    KO
    15450596
    10032013094078
    8524
    8524
    ok
    15451214
    10032013094119
    228
    4348
    KO
    15451214
    10032013097069
    978
    4348
    ok
    15451214
    10032013097071
    3142
    4348
    ok
    15542434
    10032013101736
    142
    142
    KO
    15550064
    10032013097016
    1261
    1261
    ok
    15550346
    10032013097586
    2252
    2252
    ok
    15550353
    10032013098446
    2617
    2617
    ok
    What i need : In "cost", I need to have the sum of each cost which are above 300 in one line (without showing the invoice id)
    order num
    cost
    Total
    Total2
    15450307
    1671
    1737
    ok
    15450596
    8524
    8524
    ok
    15451214
    4120
    4348
    ok
    15550064
    1261
    1261
    ok
    15550346
    2252
    2252
    ok
    15550353
    2617
    2617
    ok
    How is it possible to use a filter on a dimension without showing it or merge 2 attributes of the same dimension ?
    The problem is that if I show "id" column, the filter doesn't work properly : it compares 300 with the total cost of the whole order and does not compare with each invoice (which could be under 300 ! - see "KO" in Total2 column)
    Here is the request I use to generate this result :
    with
    member [Measures].[Total]
    as (
    [TP].[ID INVOICE].[All],
    [TP].[ORDER NUM].currentmember,
    [Measures].[COST]
    member [Measures].[Total2]
    as (
    IIF([Measures].[COST] >
    300, "ok",
    "KO")
    select
    {[Measures].[COST],[Measures].[Total],[Measures].[Total2]}
    on
    columns,           
    Filter
                 [TP].[ORDER NUM].[ORDER
    NUM].members *
                 [TP].[ID INVOICE].[ID
    INVOICE].members
                 ,[Measures].[COST]
    > 0
    on
    rows
    FROM [MYCUBE]
    Thank you  for your help !
    Kind regards,
    Olivier.

    Hi Olivier,
    hereunder a similar query against the AW. For all order numbers, we sum all lines above 30 without diplaying the line numbers:
    WITH
    MEMBER [Measures].[lines above 30] AS
    IIF(
    [Measures].[Internet Sales Amount] > 30,
    [Measures].[Internet Sales Amount],
    null
    MEMBER [Measures].[aggr lines above 30] AS
    SUM(
    exists(
    [Internet Sales Order Details].[Sales Order Line].[Sales Order Line],
    [Internet Sales Order Details].[Sales Order Number].currentmember
    [Measures].[lines above 30]
    SELECT
    [Measures].[Internet Sales Amount],
    [Measures].[aggr lines above 30]
    } ON 0,
    [Internet Sales Order Details].[Sales Order Number].[Sales Order Number] ON 1
    FROM ( SELECT
    [Product].[Category].[All Products] ON 0,
    [Internet Sales Order Details].[Sales Order Number].&[SO51177]:
    [Internet Sales Order Details].[Sales Order Number].&[SO51178]
    } ON 1
    FROM [Adventure Works] )
    I reduced the cube with a subselect.
    Philip,

  • How to use filter operator with ROWNUM

    I would like to add filter operator in my mapping with ROWNUM to reduce the ETL loading time during testing to ensure mapping is working, but I don't know how, please help provide me some guideline. Thank you.

    what is your owb version?
    Starting with Oracle Warehouse Builder 10.2.0.3, you can use the pseudocolumns ROWID and ROWNUM in mappings. The ROWNUM pseudocolumn returns a number indicating the order in which a row was selected from a table. The ROWID pseudocolumn returns the rowid (binary address) of a row in a database table.
    You can use the ROWID and ROWNUM pseudocolumns in Table, View, and Materialized View operators in a mapping. These operators contain an additional column called COLUMN USAGE that is used to identify attributes used as ROWID or ROWNUM. For normal attributes, this column defaults to TABLE USAGE. To use an attribute for ROWID or ROWNUM values, set the COLUMN USAGE to ROWID or ROWNUM respectively.
    You can map a ROWID column to any attribute of data type ROWID, UROWID, or VARCHAR2. You can map ROWNUM column to an attribute of data type NUMBER or to any other data type that allows implicit conversion from NUMBER.
    Note that ROWID and ROWNUM pseudocolumns are not displayed in the Data Object Editor since they are not real columns.
    Edited by: Darthvader-647181 on Oct 29, 2008 9:18 AM

  • How to use filter for alv display in webdynpro

    hi,
         i have use select-options and what ever data is coming from the data base i display it using alv.
    i also want to include functionality like filter and all that , that comes in normal alv.please guide me how can i do it.
    thanks

    hi please remind  that this is not the proper forum for this ...go to this
    Expert Forums » ABAP Development » UI Programming

  • How to use Filter commands in WAD?

    Hello community,
    I am desperately trying to use the command wizzard in order to set a Filter to a chrarcateristic in an 7.0 web template:
    I have been trying these commands so far but it simply doesnt work:
    SET_SELECTION_STATE_SIMPLE
    SET_SELECTION_STATE
    My problem is: When I select the charcateristic which I want to Filter, I get always the Error message, that the characteristic is not a valied characteristic or structure of the Query. But this is not true, the Characteristic is in the query. I have tried for hours now but no success.
    Thanks for any help or advice.
    Carl

    Hi Carl,
    I had the same situation. All you have to do is to update your support package. After that it will work properly.
    I have - Support Package 7, Revision 571
    Regards
    Erwin
    Edited by: Erwin  Buda on Dec 5, 2008 9:47 PM

  • How to use filter vis and peak detectors in compactRio

    Hi  all,
               We are
    using compact rio 9002 with IO module 9215. We are accessing a sine
    wave(of 1 KHz) input with some DC components in it. We need to filter
    out the DC and get the peak value of that sine wave. We have developed
    a program to acquire the same. But the problem we are facing is we are
    not able to filter out the DC and get the peak values inspite of using
    the filter and peak detector VI's. Suggest the reason and the solution.
    Regards,
    Labview Lovers.

    Hi Shivkumar,
    If you need to filter out the DC portion of the signal before you acquire the signal you may want to consider implementing AC coupling.  Which particular Filter and Peak VIs are you using?
    Regards,
    Bassett

  • How to use a Servlet to do HTTP streaming?

    Hello, everyone!
    I want to use a servlet to do simple HTTP streaming, just like what Apache is doing now. I just want the basic functions of HTTP streaming. I want the Servlet works like this, reads data from a local media file and sends through HTTP to client player to do streaming.
    Where can I find some sample source codes?
    Best regards,
    George

    Can anyone help?
    George

  • How to use filter

    My application has many threads. Each thread is sending messages to queue Q1 with unique corrlation id' and is waiting
    The application that process these messages places response with the same corlation id in another queue Q2.
    I need to capture right messages from Q2 to right threads based on corrlation id.
    Please explain how to do that. I searched for some help on filters , but I could not get any usefull help.
    Thanks!

    Hi,
    What you really want to use is a QueueRequestor that will do the job for you i.e sends a request and waits for a reply. The temporary queue is used for the JMSReplyTo destination, and only one reply per request is expected. You code should be like that:
    QueueRequestor requestor = new QueueRequestor(session, destination);
    TextMessage request = session.createTextMessage(CLASS + ": Sample Message");
    Message response = requestor.request(request);
    Hope it helps.
    Arnaud
    www.arjuna.com

  • How to use Filter in SDK

    Dear sir,
    Iam using SAB B1 2005 pl : 5.
    In purchase order form itemsection , when i press a TAB in Item No field it shown all the items. I want particular Item group and user based items are shown. how to do in SDK pl give some sample code how to do ?
    Regards
    Jambu

    Hi,
    You have to add some conditions to the choose from list of particular column.
    You can use the following code for adding conditions.
    For executing above code, first you have to get CFL id of particular column of the matrix.
    By getting the id u can set the conditions for that particular CFL.
    So you can achieve the output according to your requirement.
    For adding conditions to the CFL see the conditions object example given in the sdk help file.
    Also see the ChooseFromList sample given in the SDK samples..
    Hope this Helps You,
    Regards,
    Jagadeesh.v

Maybe you are looking for

  • Need to run the JOB without Ineractive Screen

    Dear All, We have written a new ABAP program for executing the Macro background Job and used JOB_OPEN,JOB_SUBMIT and JOB_CLOSE Function Modules to run the JOB from ABAP Program.  We are able to run the JOB successfully for Any other ABAP Programs thr

  • Editing  a Web site SWF file

    Funky, allow me to try again. right words are difficult for me come by but I try. I have a Web site that uses a 260K Swf file for presentation. My original designer is no longer available. I am trying to make changes to update some of the info on the

  • Check number field coming in blank

    I am new to this forum, and I am searching but canu2019t find a solution. I have a database, which contains a field called u201CCheck Nou201D, which contains the check numbers as well as type of payment received from a contributor. So, if the contrib

  • Adding Days to MCAL_DAY_DT in RPD to create a Clawback Dt

    I am trying to add 150 days to my existing record for Posted On Date. The datatype is Date. I am willing to perform this operation in the RPD or Answers. Any suggestions?

  • Using MAPI with JavaMail

    I want to use MAPI protocol to send mail. Is it possible with java mail API. I would appreciate if some body can give me a solution. Thanks Saikumar