• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

how to split a long form to forms ?

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to collect some data from the user, so I want the user start step one by filling up a form when she submit she will go to step two,..until the last step, could you please give me an example on how to do it.
thank you.
[ August 23, 2005: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Separate the form elements into logical pages, at each step save the form parameters in a Map, add that Map to the session, then when the final step has been submitted read out that Map from the session and do something with it.

In a nutshell thats about it... there are probably many other ways to do it, but here is one for starters
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How you do something like this depends on your requirements.

Do you want people to be able to leave a partially filled out form and come back to it another day? If so, then saving the pages in session won't work. You'll need to write them to your database.

If they are to fill the entire thing out in one sitting, using session as Daniel mentioned could be the easiest way.
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Daniel,
I am new to this, I have never used Map in jsp, could you please give me a small example.
thanks.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a JSP with scriptlets, you can use Maps in exactly the same way as plain java. Just remember that they're stored in the session.

<% Map m = (Map)session.getAttribute("myMap");
m.put("inputName", inputValue);
%>

If you're using scriptless JSPs, you can either use beans or store the values in the map inside a servlet before forwarding to the next JSP.

-Yuriy
[ August 24, 2005: Message edited by: Yuriy Zilbergleyt ]
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you're using scriptless JSPs ...



Nothing prevents the use of Maps or the session when writing scriptless JSPs.

Another approach I've seen used is to carry all the values from page to page via hidden inputs. Much wordier and messier than the session mechanism, but another possibility.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nothing prevents the use of Maps or the session when writing scriptless JSPs.



My bad, forgot all about the <c:set> tag. I guess this is what happens when you only use scriptless JSPs when studying for the certification exam...

-Yuriy
 
Message for you sir! I think it is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic