Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2008

Tip: Looking for answers? Try searching our database.

Keeping form input values

Thread view: 
francan00@yahoo.com - 19 Feb 2008 00:41 GMT
I am going to create a form that will have about 3 pages of inputs in
one form.
The first and second page will have continue button and the final page
(3rd page) will have the submit (into database) button.

What is the best way to forward the form inputs from each page so all
will be submitted?

I will use MVC architecture but dont have Struts on our Tomcat 4.1.27
container.
Wojtek - 19 Feb 2008 20:11 GMT
francan00@yahoo.com wrote :
> I am going to create a form that will have about 3 pages of inputs in
> one form.
[quoted text clipped - 3 lines]
> What is the best way to forward the form inputs from each page so all
> will be submitted?

Create an object which will hold all the form inputs, and store that
object in the user's session. You can also store state, so you know if
the user clicks on the Back button, or tries to go to page two without
first going to page one.

Signature

Wojtek :-)

francan00@yahoo.com - 20 Feb 2008 01:53 GMT
> franca...@yahoo.com wrote :
>
[quoted text clipped - 13 lines]
> --
> Wojtek :-)

Thanks,  I assume I can create an object using JavaBean class where I
will take all the fields (via getter and setter methods) and use a
special method to grab all the fields into one object.  Then call that
special method in my Servlet?
Lew - 20 Feb 2008 02:19 GMT
> I assume I can create an object using JavaBean class where I
> will take all the fields (via getter and setter methods) and use a
> special method to grab all the fields into one object.  Then call that
> special method in my Servlet?

That's one way, although you don't really need any method more special than
doPost(), unless things get large enough to refactor.

You could also, for example, use the ServletRequest method getParameterMap()
and work directly off the Map of parameters:
<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getParam
eterMap
()>

This has the advantage of grabbing all the parameters in one fell swoop, and
the disadvantage of leaving all the parameter values as unvalidated Strings
packaged in the String [] values of the Map.

Signature

Lew

Wojtek - 20 Feb 2008 18:14 GMT
fr-)ancan00@yahoo.com wrote :
>> franca...@yahoo.com wrote :
>>
[quoted text clipped - 17 lines]
> special method to grab all the fields into one object.  Then call that
> special method in my Servlet?

Well, you CAN use a bean, but a simple class will also do. Extracting
form fields from the request is not all that difficult, and it lets you
condition the information, for things like valid input, ie: all numbers
for a numeric value, and within bounds, so that  month value is within
1 and 12 inclusive.

NEVER assume that the user is kind enough to always enter valid values
:-)

Signature

Wojtek :-)

francan00@yahoo.com - 20 Feb 2008 22:44 GMT
Thanks Lew and Wojtek!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.