Token session interceptor not submitting modfied form - struts2

I am using struts2 framework for my application.I have two pages. Page1 with form1 having modifiable data and submit button. I am using token session interceptor to prevent form re submission . On clicking submit from page1 it will call an action and navigate to Page2 and show the success/failure result.
The problem is if I use browser back button from Page2 to navigate back to Page1 and modify some form1 data and click submit, token session interceptor not calling the action again instead navigating to Page2 with previous result .
While using browser back button I need to prevent form re-submission if there is no change in data, on the other hand I need to submit the data if there is a modification.

You need to tell the browser not to cache anything, so when the back button is clicked, the browser tries to load the page again. For this purpose you need to write a caching interceptor that will set headers to response to instruct the browser to not cache pages. See Why after logout clicking back button on the page displays previous page content.

Related

Logout or Expire Session In Vaadin

My question, Is this possible in vaadin to logout or expire session on page refresh and also expire user session if site is opened in another tab of same browser and redirect the user to login page.
Im using VaadinSession.getCurrent().setAttribute() function
I think by logout you mean removing some attribute from the session.
You can do this in the UI init method. It is called everytime a new tab is opened or F5 is pressed. Different Tabs in the same Browser share the same session.

Spring Security modal login done right

I know how to implement a spring security login form the "classical" way, but I'm having a hard time figuring out how to implement a login form that opens in a modal and always behaves "properly".
It is not as trivial as it sounds.
Here are my specifications:
when an unauthenticated user requests a protected page, a modal login form should appear; when the login is successful, the requested page should appear and the address bar should display the requested url as in a non-modal approach
when this is triggered from outside the site, the modal should open on the site home page
when this is triggered from inside the site, the modal should open on the current page
when a user clicks on a "login" button on the site header (from any unprotected page) a modal login form should appear without changing page; when the login is successful, the location should not change but the page should be reloaded in order to be updated (e.g. showing the user name in the header)
if the modal is closed before submission, the original page should not have changed
if there are login errors, they should appear in the modal without redrawing the whole page
if the login form is submitted after session expiration, the login process should handle expired CSRF tokens gracefully (but I might consider removing them altogether for the login form, where I don't think are needed anyway)
every ajax request on the site (that originates from a protected page), should handle login requests gracefully
brute-force attacks should be hampered by temporarily suspending a username after some failed attempts
Java-only Spring configuration (no XML) and JQuery
the logout link should not trigger an authorization error when the session is expired

Refresh Registration page after submitting

In my site, I have made a registration page named registration.php. When I submits it redirects to reg_success.php. But If i press back button after my succesful registration, then also the registration page i.e registration.php remains filled. I want that if my registration is complete and I press back on browser then my registration page should come blank.
Kindly help me, what code I need to add to the registration page on clicking back on browser.
Use following line of code :
window.location.reload();
or also you can use following way :
window.location.href = window.location.href;

logout does not work properly in struts2

i am developing a struts project.
In login page action stored username and password in session.
In logout action class using session.invalid and removed that session details and redirected to index page.
But i click back button in browser it goes to the previous page.
Now i need sample code for if i am clicking back button after logging out it will show the error message or it display index page like yahoo mail.
need sample for that in struts2
As I know, very hard to do JS side. because back button belong to web browser. Our project do below way:
When logout, close currently window and open new window. that will help you clear history.

login page via popu-up window

Is there an example login page via a pop-up window?
Also, if the user performs some operation on the site that requires authentication, then show the login screen (if user not authorized).
You should just create you Login view, as you would implement it usually. And then apply fancybox (http://fancybox.net/) or bootstrap-modal(http://twitter.github.com/bootstrap/javascript.html) to make it work as modal.
Regarding re-direction: as soon as you use [Authorize] attribute as controller attribute and not-authorized user tries to hit its action, he will be redirected automatically;
you may use modal box plugins for jquery to create pop-up and place your log-in form in the pop-up.
Check out this modal window plugin which support html markup in the popup.
http://www.zurb.com/playground/reveal-modal-plugin

Resources