• Post Reply Bookmark Topic Watch Topic
  • New Topic

Failed to redirect to login page after logout  RSS feed

 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have problem in J2EE web application. It refuse to redirect to login page after clicking logout button. Its working perfectly working in IE but not in Chrome. After clicking logout button in Chrome browser, its loading the page. only loading and show a white blank page. Below is what I did for logout

logout.jsp


After that, it will go to another jsp file

logout.jsp


Anyone know what I did wrong? Or did I missed anything? Really in need for help 
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding some headers and see if it makes any difference

 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:Try adding some headers and see if it makes any difference



I already create that one. I create a new java file for noCacheFilter.
 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I did in noCacheFilter.java

 
Dave Tolls
Ranch Hand
Posts: 2658
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having Java code like that in your JSP is not good.

That code should be in a servlet.
 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Having Java code like that in your JSP is not good.

That code should be in a servlet.


Oh really? Actually it works in IE browser but failed in chrome. Which code? All code in the jsp?
 
Stephan van Hulst
Saloon Keeper
Posts: 7385
130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs should only present the data given to them. Servlets are responsible for retrieving and processing data. They should pass the finished data to the JSP in what's called a "view model". JSPs just pull data out of the view model and put it inside the template.
 
Dave Tolls
Ranch Hand
Posts: 2658
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nieyna nano wrote:
Oh really? Actually it works in IE browser but failed in chrome. Which code? All code in the jsp?


Servlets are the entry point(s) to your app.
JSPs are what servlet forward to after gathering/processing data.
All a JSP does is display it.

This isn't necessarily something that'll have any effect on your current problem, but it is an issue, if nothing else because a JSP page is a swine to debug.
 
Stefan Evans
Bartender
Posts: 1835
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nieyna

So if I understand correctly your application flow is

- User clicks logout link/button in your app
- Calls logout.jsp in one web application - invalidates the user session
- redirects to the BIS web application logout.jsp - invalidates the user session there
- redirects to "loginMenu.jsf"

You have a multiple web app architecture?
So it has to invoke logout in both web apps?
Which web app hosts the loginMenu resource?

Chrome does have a feature that caches redirect requests.

Using the F12 developer tools can you see how far through this logout process it gets before hitting a blank page?
There are multiple requests going on, and any of them could be the cause.

 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Hi Nieyna

So if I understand correctly your application flow is

- User clicks logout link/button in your app
- Calls logout.jsp in one web application - invalidates the user session
- redirects to the BIS web application logout.jsp - invalidates the user session there
- redirects to "loginMenu.jsf"

You have a multiple web app architecture?
So it has to invoke logout in both web apps?
Which web app hosts the loginMenu resource?

Chrome does have a feature that caches redirect requests.

Using the F12 developer tools can you see how far through this logout process it gets before hitting a blank page?
There are multiple requests going on, and any of them could be the cause.



Yeah. It is correct. I tried to use chrome console to find out where it stop. Below is part of my code in loginMenu.jsp


It stop at window.location=self.location;. I search through internet and it stated that chrome does not support this. I tried to change to another method but it still the same. Any idea?
 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. I post the wrong code. This is part of my code in loginMenu.jsp

 
Stefan Evans
Bartender
Posts: 1835
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really need that javascript?

You've added no-cache headers to all your pages.
Even if you do try to use the back button, it should send the request to the server (as the page wasn't cached) and your server should send you to log in again.

What happens right now in Chrome?
Does it still have all your page history?
Can you go actually back to those pages and see them without logging in again?


 
nina nan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Do you really need that javascript?

You've added no-cache headers to all your pages.
Even if you do try to use the back button, it should send the request to the server (as the page wasn't cached) and your server should send you to log in again.

What happens right now in Chrome?
Does it still have all your page history?
Can you go actually back to those pages and see them without logging in again?




I need that javascript. Before this, it just loading after logout. It refuse to go to loginMenu. I tried and search chrome does not support window.location.reload.
I search for other alternative and found window.location.href. I change from reload to href and it works.
 
Matt Keller
Ranch Hand
Posts: 32
1
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is one that has worked for me in past.  Yes, I agree with some posters here that scriptlets in your jsp are bad practice in general, but I think this is one of the exceptions where it makes sense.

Its a logoff.jsp file.  Notice how the session is killed when this jsp in rendered server side, then when the browser receives the page it forwards to the context root.  Since the session is dead the servers security should show the login page.

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">   
        window.location = "/" + contextRootPath;   
    </script>
</head>
<body>   
</body>
</html>
<%
    if(session != null) {
        session.invalidate();
    }   
%>
 
Matt Keller
Ranch Hand
Posts: 32
1
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A clarification on the previous post.  You need to substitute your context root name for "contextRootPath".  It is not a special js variable or something like that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!