I have four relevant jsp pages (plus other jsps)namely main.jsp, controllerPage.jsp, page1.jsp approval.jsp, page2.jsp, page3.jsp and its code shown below in the code block.
The main.jsp has a submit button, when user clicks on it displays page.jsp via controllerPage.jsp. The pag1.jsp also has a submit button. Upon clicking on its button it displays page2.jsp. Page2.jsp has its own submit button and upon clicking on it displays page3.jsp. Page3.jsp has no Submit button.
When the user clicks on the browser back button when the user is on page3 it takes them back to pag2.jsp. Since I am using Request scope Java Bean I do not want the user to go back to page2.jsp because java bean instance will be different at that point and as a result run time error is encountered if the user clicks on the submit button on page2.jsp again (after going back to page2.jsp by clicking on browser back button on page3.jsp)
In order to prevent this problem I used onunload function in the page3.jsp to take the user back to main.jsp. The code does take the user back to main.jsp instead of page2.jsp. When in the main.jsp, user can still click on browser back button again. In that case it takes the user back to page1.jsp (because of history registry). To prevent the user taking back to page3 when clicked on browser back button for the same reason explained above (when in main.jsp) and make the user stay on main.jsp I again used onunload function in the main.jsp. This does keep the user in the main.Jsp page. Although it did solve the problem it creates a different problem.
The above conditional statement resolved the problem. But when the user gets to page1 and from there to page2.jsp from there to page3.jsp and tries to use the browser back button when in page3.jsp it does take the user back to main.jsp as expected behavior but when the tries to use the browser back button again in this same main.jsp it take the user to page1.jsp. I was expecting it will make the user stay on the main.jsp. I think this is because the conditional statement
does not get execute although the value of it is blank.
Here are the questions:
1. Why is that, the conditional statement in the main.jsp does not execute when the user attempts to use the browser back button on this page. Is this because browser user cached main.jsp page? Also notice that the onload function in the main.jsp does not get executed when the user arrived on this main jsp from main.jsp or from page3.jsp.
2. As an alternative solution to prevent user going back words, I thought of passing a parameter/value indicating browser back button was pressed/clicked by user. The question is How to pass a parameter form a displayed page to the previous page?
3. The other alternative solution is that instead of preventing the user going back to the previous page, just allow the user to go to the previous page but disable the Submit button in the previous page if arrived there using browser back button in the page ahead of it. In order to do that I need to know the answer to previous question (question 2).
I am not clear what you mean by "Fix the backend so the user can go back" Would you please explain to me again.
Please note that going back is not an issue or problem. As stated in my questions in my first posting, I have two ways what I want to accomplish:
But the above conditional statement does not execute and hence it goes back to page1.jsp. This may be because the displayed main.jsp, after user uses the browser back button when in main.jsp, is a cached page(not built in the server)
If the conditional statement is removed meaning with just
then it stays on main.jsp.
Alternatively, just disable the submit button on page1.jsp when user arrives on page2.jsp from page1.jsp In order to do that I need to know whether user came to page1.jsp from main.jsp or page2.jsp.
To explain more clearly, let us say user just started the application using main.jsp and enters the relevant html text element data and then clicks on submit button on the main.jsp it takes the user to pag1.jsp. Now when the user clicks on submit button on pag1.jsp it takes the user to page2.jsp. At this point let us say user uses the browser back button on page2.jsp, which takes user to pag1.jsp.
The point is that user can arrive on page1.jsp from main.jsp or page2.jsp. When in page1.jsp I need to know which way user came to page1.jsp. One way to know is that I can check in page1.jsp the lcCalcBean in the server to see whether the value of submit is "Approve" if so I know user came to page1 from page2.jsp. Unfortunately I can not do that because one can only execute JSP tag code in the JSP page only at JSP factory on the server (At the time of building a new page upon cetain action by the user like cliking on a button etc.) In other words java tags does not get executed on a loaded page from cache ( in this case page1.jsp is a cached page displayed from the history when user used browser back button on page2.jsp.
In this case 2 the question remains How one can know wether user arrived at pag1.jsp from main.jsp or page2.jsp. Unless I know this I cannot disable the Submit button on pag1.jsp.
I have only two days to resolve this problem. I hope I get a good response from some one to resolve issues listed in either of the two approaches mentioned above.
Thanks for the suggestion I will learn about it for my new project. But for now it would be helpful to know how I can resolve the issue I have presented in approach 1 and approach 2 above.
posted 8 years ago
Can any one give some idea about how to resolve approach 1 or 2 posted in my previous udpate. Management at my present job wants me to figure this out before I leave my present job. I've only a couple of days left - perhaps until Monday.
You have already had good advice from people who know what they are talking about. If you reject that advice you aren't likely to get any other advice. Good luck in your next job, hopefully you won't be stuck with implementing bad requirements there.
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
how do I do my own kindle-like thing - without amazon