This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes how to Autosave the changes when the page is changed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to Autosave the changes when the page is changed?" Watch "how to Autosave the changes when the page is changed?" New topic
Author

how to Autosave the changes when the page is changed?

shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
hi all,
I am doing pagination in jsp and here is my code for pagination:

----------------------------------------------------------------



---------------------------------------------------------------------------
I am retrieving 10 records per page passing the start value to servlet depending on which the servlet retrieves alues from database. Now my problem is i have to auto save the current page before moving to another page when i click on next or previous. Is there any way to do that?
thanks in advance

[BPSouther: Added code tags]
[ November 14, 2007: Message edited by: Ben Souther ]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Assuming you are talking about saving to the backend, then you have to call a method that will do it when the button is clicked.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
I want to save the data to database. I am using two servlets one to retrieve the data from the db and another to save to db. In my pagination code i am retrieving data from database.The user can edit the data retrieved from db so i want to save the changes made by the user before going to next page to avoid loss of changes if the user accidently clicks on previous or next button.How to call both the servlets on single click?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is no concept of "autoSave" in HTML, Servlets or JSP.

If you want to save changes while paging then you will need to modify your code to post all forms and do the writes while paging.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
I think you didnt got my problem. I am using anchor tag which calls the same jsp page with different start index so the user gets next 10 or previous 10 values. Till now i was calling one servlet when the user clicks on next or previous image. Now i want to call the same jsp page as well as servlet which saves the data of my current page to database. My problem is how to call the same jsp page and at the same time call servlet.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I did understand your problem.

If you want to save the data on the current page when you move to the next page, you'll need to update your pages submit a form with the data from the current page when moving to the next (instead of using anchor tags).

This will probably also require that you re-work your servlet code so you can move to the next page after a form submission.
shashank bezalwar
Greenhorn

Joined: Oct 31, 2007
Posts: 17
Thanks for your advice i will use form instead of anchor tags.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Javaranch tip:

Code like this (with nested branch statements) is extremely difficult to read if it's not formatted correctly.

See this to learn how to wrap your code in UBB Code tags which will preserve your indenting, increasing the likelihood that someone will actually read it and help you in the future.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Assuming you are talking about saving to the backend, then you have to call a method that will do it when the button is clicked.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to Autosave the changes when the page is changed?
 
Similar Threads
special characters in JSTL
Implementation of google charts in JSP
Best choice for pagination?
How to do database pagination using JSTL tags
quick paging calculation question