File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet" Watch "servlet" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have three pages of static html and the last page has
submit button. I want to put all the data into database when
i hit the button. This part I can do using servlets, but i want to know how to get data from the previous html page.
It is a online form with three html pages.each html page leading to the other.
If u have any idea of how to go about please help me.

Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The standard way to do this is to link the pages via a servlet, rather than just a raw hyperlink. For example:
Page 1:

Page 2:

When the servlet receives a POST request it checks the value of the "action" parameter. If it is "Go To Page 2" then it saves the first page of information in a temporary place (in the current session for example), then displays the second page. If "action" is "Finish", it retrieves both the stored temporary data from page 1 and the parameters from page 2 and processes them together.
I've used this technique for both sequential multi-page forms and more complex "tabbed" pages where the user can select them in any order.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
S Varana

Joined: Feb 04, 2004
Posts: 18
Thanx for ur suggestion
I am using anchors to navigate. I have to use them .
Now can i place a hidden button which gets invoked without user's knowledge and which does the storing of temporarry data thru servlets.
Any ideas of how to go about like how will my hidden button get focus automatically etc etc.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
You don't need a "hidden button", just some JavaScript. Any link can have an associated "onClick" handler, so just put a little code to submit the form in it. For example:

I'm puzzled as to why you "have to use" an anchor. Can you clarify this? Are there other important restrictions?
S Varana

Joined: Feb 04, 2004
Posts: 18
I tried ur code but gives me error saying object
does'nt support this property or method.
What is the problem?
Thanx for ur reply.
I agree. Here's the link:
subject: servlet
It's not a secret anymore!