Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

response.senRedirect does not seem to be working in filter

 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
JSP_Setup.JPG
JSP setup
[Thumbnail for JSP_Setup.JPG]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What leads you to believe that the right conditional part is being executed?
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic