File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preventing Browser Navigation

 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What are the standard ways to prevent a user from navigating with the *back* or *forward* of his browser.
Is theer a special tip to prevent the *CTRL-N* too.
TIA
[ March 08, 2002: Message edited by: Bill Bailey ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question turns up very often and you might want to do a search in the HTML and JavaScript forum.
There isn't really any stable manner to do this on the client side, you can get better control over what gets shown to the client using the MVC pattern with a 'Front Controller'.
DOM
 
arun mahajan
Ranch Hand
Posts: 305
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear David,
No doubt this is something related with javascript and HTMl but a very basic requirement on shopping cart etc.
By the way what is MVC pattern ? How can we use it? Any reference site for same?
regards,
Arun Mahajan
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't find the thread I was looking for, but if you search the JSP and Servlet forums, there are several threads refering to the MVC architecture.
It will also help your searches if you know that 'MVC' (or Model-View-Controller) is a concept stolen from the SmallTalk language. It is often refered to as the 'Model 2' architecture in web apps.
Also of use will be the article on Struts written by our own Thomas Paul in the March version of the JaraRanch Newsletter.
(note that Struts helps code the MVC pattern, as opposed to 'being' the MVC pattern)
DOM
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
If i didn't post my thread into the HTML/Javascript thread, it's because I'm not interested in that kind of solution.
What want is a server-side way of solving the problem.
You mentioned the MVC, ok, interesting point.
But please go a little bit further.
What kind of "stuff" do you implement in your controller to handle the "back/forward" problem ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the MVC pattern there is a variant (sometimes called 'Front' or 'Global' Controllers) where all requests, regardless of what the client is asking for or who the client is, get made to the same Servlet.
This servlet decides which page gets sent to the client. There are a few options, but basically you decide on a flow of pages and make sure they get Page2 after they see (and complete) Page1.
In this scenario, if they use the back button and it results in the page being re-requested (by disabling caching etc), they think they are going from Page2 back to Page1, except that the Front Controller decides to send them Page2 again, since that is where they are supposed to be in the web app.
Therefore the forward and back buttons haven't been disabled or taken over, but they aren't any use to the client.
Opening a new window (as long as it shares the same session) works the same. The client can now have 2 windows showing the same page, and it is not recommended since it may be possible to 'corrupt' the data on the server, but they still can't get to a page they aren't supposed to.
Dave
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David.

What I understand is :
1- I have to disable caching in all my jsp pages
2- So each back/forward , refresh and CTRL-N will actually requests the server
3- then my front controller can handle the request
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you are on your way.
You will find it easier in the long run if you use Struts (and have a look at the article by Thomas Paul).
Make sure you design the transitions from state to state in a stable manner, since its very easy to get wrong. (and don't use frames, then you'd be maintaining the state across multiple pages...)
Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic