aspose file tools*
The moose likes JSP and the fly likes response.senRedirect does not seem to be working in filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "response.senRedirect does not seem to be working in filter" Watch "response.senRedirect does not seem to be working in filter" New topic
Author

response.senRedirect does not seem to be working in filter

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Code snippet from RequestFilter



Now, the interesting part, Please see the attached file.

Now, what happens when my session expires (due to inactivity) and I click on any of the tabs , it opens up the login page into that 'Main body part'. But I am actually redirecting the request, should not it change the browser URL and load the login page?



[Thumbnail for JSP_Setup.JPG]

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What leads you to believe that the right conditional part is being executed?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Because I can see my login page into that Right conditional Part (which I referred as Main Body Part) as well as I can see from the log that it goes into that if condition and prints logger statement.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

There's something about "Ajax" in that image you posted. If you see the login page appearing inside a frame in your browser, then that means that the request for the login page came from that frame.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Paul Clapham wrote:There's something about "Ajax" in that image you posted. If you see the login page appearing inside a frame in your browser, then that means that the request for the login page came from that frame.


That images shows the JSP staructure. We have used AJAX there. When you click on any tab/link link on left portion of JSP , it updates (through AJAX) the right side portion of the JSP. Now I have implemented filter to make sure that when user session expires due to inactivity, and then user click on some link, she should be taken to login page. That happens right now. But rather doing *sendRedirect* it just loads the login page in that right side portion of the page. If you see my filter code, I have written sendRedirect and logs on server confirms that it goes into that method.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
ok, nowadays AJAX is used in almost every app. Do you use that?
How do you manage if session expires automatically? Do you redirects to login page?
If you use ajax and do redirect then how did you implement that? (any way other than the way have implemnted?)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

I use lots and lots of Ajax. Whenever the authentication filter detects that the user requires authentication, it returns a custom status code in the response (555 to be exact). The client detects this status code and initiates the login protocol.

This is incredibly easy to implement if you are using something like jQuery to do your Ajax, as you can establish a global event handler for all Ajax errors rather than testing it each and every time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.senRedirect does not seem to be working in filter
 
Similar Threads
How to know login & logout status of user
Session Management with Ajax
Problem in redirecting to the index screen
sendRedirect and CSS!
Session Validation Filter