473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Browser back/forward button and Java Servlets

Hi everybody,
for my web-application (it must currently work only under IE6) I have
a servlet that intercepts user's HTTP GET requests for a typical
search result page, which contains a paging mechanismus for navigating
between the result pages (e.g. << 1 2 3 4 5 ... >).

When the user clicks on this navigation, the JSP send a GET request to
a servlet wich does some buisiness logic - in particular it logs (with
log4j) how many times an user navigates between the several pages and
then sends the response back to the client with the next search
results page. Everything works fine.

BUT if the user hits the browser's back/forward buttons, the servlet
which contains the counter for the log file will be never called from
the JSP, and so the counter will not increase its value for the log-
file.

I must handle this back/forward event (as well as, when the user
clicks the right mouse button to navigate the history - back or
forward).

I have no idea how to catch the event and calling the servlet for
incrementing the counter.... and the business sets me more and more
under pressure :-(

Does anybody has an idea, suggestion, or a link with an example?

Thank you very much for your suggestions :-)
John

Apr 11 '07 #1
4 6240
John wrote:
Hi everybody,
for my web-application (it must currently work only under IE6) I have
a servlet that intercepts user's HTTP GET requests for a typical
search result page, which contains a paging mechanismus for navigating
between the result pages (e.g. << 1 2 3 4 5 ... >).

When the user clicks on this navigation, the JSP send a GET request to
a servlet wich does some buisiness logic - in particular it logs (with
log4j) how many times an user navigates between the several pages and
then sends the response back to the client with the next search
results page. Everything works fine.

BUT if the user hits the browser's back/forward buttons, the servlet
which contains the counter for the log file will be never called from
the JSP, and so the counter will not increase its value for the log-
file.

I must handle this back/forward event (as well as, when the user
clicks the right mouse button to navigate the history - back or
forward).

I have no idea how to catch the event and calling the servlet for
incrementing the counter.... and the business sets me more and more
under pressure :-(

Does anybody has an idea, suggestion, or a link with an example?

Thank you very much for your suggestions :-)
John
I'm guessing that what's going in is that the browser is loading a
cached back page, so it goes back to the cached page and sends no
request to the servlet. If this is the case, then sending a simple AJAX
request using a window.onload handler to get the servlet to recognize
the back should be sufficient.
Apr 12 '07 #2
Joshua Cranmer said the following on 4/11/2007 10:43 PM:
John wrote:
>Hi everybody,
for my web-application (it must currently work only under IE6) I have
a servlet that intercepts user's HTTP GET requests for a typical
search result page, which contains a paging mechanismus for navigating
between the result pages (e.g. << 1 2 3 4 5 ... >).

When the user clicks on this navigation, the JSP send a GET request to
a servlet wich does some buisiness logic - in particular it logs (with
log4j) how many times an user navigates between the several pages and
then sends the response back to the client with the next search
results page. Everything works fine.

BUT if the user hits the browser's back/forward buttons, the servlet
which contains the counter for the log file will be never called from
the JSP, and so the counter will not increase its value for the log-
file.

I must handle this back/forward event (as well as, when the user
clicks the right mouse button to navigate the history - back or
forward).

I have no idea how to catch the event and calling the servlet for
incrementing the counter.... and the business sets me more and more
under pressure :-(

Does anybody has an idea, suggestion, or a link with an example?

Thank you very much for your suggestions :-)
John

I'm guessing that what's going in is that the browser is loading a
cached back page, so it goes back to the cached page and sends no
request to the servlet. If this is the case, then sending a simple AJAX
request using a window.onload handler to get the servlet to recognize
the back should be sufficient.
That won't work as the onload event isn't always fire when the page is
retrieved from the cache.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 12 '07 #3

"Joshua Cranmer" <Pi*******@epenguin.zzn.comwrote:
John wrote:
>Hi everybody,
for my web-application (it must currently work only under IE6) I have
a servlet that intercepts user's HTTP GET requests for a typical
search result page, which contains a paging mechanismus for navigating
between the result pages (e.g. << 1 2 3 4 5 ... >).

When the user clicks on this navigation, the JSP send a GET request to
a servlet wich does some buisiness logic - in particular it logs (with
log4j) how many times an user navigates between the several pages and
then sends the response back to the client with the next search
results page. Everything works fine.

BUT if the user hits the browser's back/forward buttons, the servlet
which contains the counter for the log file will be never called from
the JSP, and so the counter will not increase its value for the log-
file.

I must handle this back/forward event (as well as, when the user
clicks the right mouse button to navigate the history - back or
forward).

I have no idea how to catch the event and calling the servlet for
incrementing the counter.... and the business sets me more and more
under pressure :-(

Does anybody has an idea, suggestion, or a link with an example?

Thank you very much for your suggestions :-)
John

I'm guessing that what's going in is that the browser is loading a cached
back page, so it goes back to the cached page and sends no request to the
servlet. If this is the case, then sending a simple AJAX request using a
window.onload handler to get the servlet to recognize the back should be
sufficient.
Nocache HTTP response headers. I forget the exact format, but that should do
the trick.

Apr 12 '07 #4
Nocache HTTP response headers. I forget the exact format, but that
should do the trick.
If I remember correctly, this won't work in Firefox, as it has some kind
of cache (called back-forward cache?). Firefox caches pages even if you
set no-cache in http headers.
Apr 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
8
by: Beatrice Rutger | last post by:
Hi, I am a previous Micro$oft desertee (moved from VB/VC++ to Java before this whole DOTNET thing) because I had several issues with Micro$oft. I am not completely in love with Windoze, but I...
5
by: Brad | last post by:
I created a base page class which sets a response filter and the filter injects additional html into the response output stream. The filter works fine and everything works as expected except for...
1
by: Terry Olsen | last post by:
Is there any way to disable the client browser "Back" and "Forward" buttons while on my site? Or how would I go about knowing that a page hit is caused by a back/forward navigation? I have...
1
by: Jimmy | last post by:
I want to hook the "back" event or "forward" event from a browser page. How can I trigger these events to my asp.net page? ch Jimmy
5
by: ns21 | last post by:
How can the browser back button be disabled If the form is submitting information to other pages or submitting to itself or using redirections. I tried the tweaks like history.forward(1) in each...
0
by: toeffetommy | last post by:
Hello, I need a piece of functionality developed for our Website and I need some technical advice on how get there. Essentially, what I want to develop is a browser-within-browser...
3
oranoos3000
by: oranoos3000 | last post by:
hi i'm a beginer javascript would you please help me i d like to findout this page has next page or previous page in history object i use this line of code if(window.history.length>0) and with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.