CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2000
    Location
    Vancouver, BC, Canada
    Posts
    278

    redirect back to source page frma filter?

    trying to get a filter to redirect to the refering page if it doesn't pass certain criteria. if it needs to return to the referer, I add values to the request.attributes object.

    if I use request.getDispatcher(path).transer(request,response) the URL displayed is the 2nd page (which means other filters needed won't properly execute and a second submit from there leaves it thinking the refering page was 'itself'.

    if I use response.redirect(referingPage) it's fine, but now the values I need that were passed in the attributes object are lost.

    nutshelling:
    I need it to return to the original page and still show the correct (original) URI and still be able to access parameters set from the filter.

    suggestions?
    David Meikle
    Quantum Unit Solutions, LLC
    www.quantumunit.com

  2. #2
    Join Date
    Nov 2006
    Posts
    42

    Re: redirect back to source page frma filter?

    The String you pass to response.redirect(String) can have parameters. You could append a query-string "...?param1=value1&param2=value2" to the String referingPage and you can handle the parameter you thus added in referingPage (either on server side, if it is a jsp or on client side using javascript).
    Another way would be to add a cookie to the response and retrieve that cookie on the client side and read the values from it.

    Did this help ?

  3. #3
    Join Date
    Mar 2000
    Location
    Vancouver, BC, Canada
    Posts
    278

    Re: redirect back to source page frma filter?

    well I thought of that, but I have a hashmap of values generated from the results of the criteria checking filter. If I change it to cookie based, I'd need to write a whole parse cookie section on each page, plus I'm trying to make it universal to the way we do most of our coding methods on the rest of our software design.

    usually we run things through a filter and load the results of the filter into the request.attributes object for the next filter or next page. Normally I don't even resort to a hashmap (I prefer to use bean types where the object itself contains an arraylist of like objects and you simply iterate it with a while(item.next()) loop.
    David Meikle
    Quantum Unit Solutions, LLC
    www.quantumunit.com

  4. #4
    Join Date
    Nov 2006
    Posts
    42

    Re: redirect back to source page frma filter?

    Well, you can also put that hashmap as an attribute into the http session. So it does not get lost.
    Don't forget to clean it afterwards though...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured