• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Refresh in browser

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a query program which displays data page by page. I have two buttons, next and back, depending on how many rows have to be displayed. I'm using the same jsp page for displaying all pages. My jsp page uses two java beans for this. One has request scope which performs the query for every page and gets data. The other has a session scope. It keeps track of how many rows have been viewed, and shows data respective to next and back clicks.
The way I know its a next or back click, is by using request.getAttribute("next") and request.getAttribute("back"). All is fine.....until we click on Refresh button in the browser.
Suppose I get 100 rows in query, and user selects to see 20 rows per page.After seeing the first page, user clicks next button and views the next display. Now, if user clicks Refresh button in the browser(after next click), its being interpreted as another NEXT click.....if user keeps on clicking Refresh button....they will reach end of data. Without clicking next button, they would have viewed all display pages. Similar scenario happens when user clicks back button, and Refresh in browser. The program interprets the Refresh(after a back click) as another back click.
How can I distinguish if its a Refresh from the browser button, and a next or back click ? How can I handle Refresh clicks in Internet Explorer in my program ?
Any suggestions would be welcomed.
Thanks.
 
Mallika Kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Correction to my previous post......it should be request.getParameter("next") and request.getParameter("back"), not request.getAttribute("next")/("back").
Regarding this problem, is there a way we can get to know if the user has clicked Refresh button in browser ?
Thanks.
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When refresh it click, the client makes an identicle request to the server.
Since this calls the jsp and you only use one, the way you have designed it, the jsp thinks that is the next request, which it technically is.
 
Mallika Kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Andrew.
Well, the design of this program did not take the Refresh action into account. I would like some suggestions regarding how to go about solving this scenario. I have a session scoped bean with a counter variable, which tracks the rows viewed. I was thinking of re-setting this variable to be equal to what it was at the beginning of the page display, when refresh button is clicked. But before I do that, I need to know that refresh is taking place. Is there a way to get this information from the request, or server ?
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mallika,
I also once had to write those 'Prev' 'Next' - type of work.
The trick used was, dynamically generate those 'Prev' and 'Next' href links and append 'PageNo' in url itself.
For example :
<a href="http://localhost:8080/servlet/EmployeesServlet?pageNo=10> Next Page </a>
OR
<a href="http://localhost:8080/servlet/EmployeesServlet?pageNo=10> Prev Page </a>
What your EmployeeServlet will do is, just get 'PageNo' HttpServletRequest value and calculate those rows to be displayed and display. Apart from this, it will also intelligently calculate if there could be Next/Prev links for this current page and dynamically coin those hrefs and place them at top/bottom of page.
In this case , if we click on referesh, I think the current page only will be displayed , because the vital 'pageNo' info comes from Prev/Next hrefs itself (not from session) . Give it a try!
regds
maha anna
[This message has been edited by maha anna (edited May 10, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic