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 / June 2005

Tip: Looking for answers? Try searching our database.

Form Parameters

Thread view: 
Kevin Robinson - 09 Jun 2005 15:46 GMT
Can anyone please advise me with a problem.

I have a JSP which sends parameters originating from text fields to a
servlet.
This works OK.

I now want to add several buttons to the jsp form and want to  pass a
parameter
to the servlet telling it which button was pressed.How do I do this?

Thanks

Kevin
Chris Smith - 09 Jun 2005 15:53 GMT
> Can anyone please advise me with a problem.
>
[quoted text clipped - 5 lines]
> parameter
> to the servlet telling it which button was pressed.How do I do this?

Give each submit button a different "name" attribute.  The values should
be ignored, since they are the text of the button itself, but you should
compare the names of the form parameters against those that you know
mean each button.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Kevin Robinson - 10 Jun 2005 08:57 GMT
OK If  I have <input type="Submit" name="AddProduct" value="Add Product">
Is the name "AddProduct" automatically sent to the server when the button is
pressed or do I need to do something else with the name first?

> > Can anyone please advise me with a problem.
> >
[quoted text clipped - 17 lines]
> Chris Smith - Lead Software Developer/Technical Trainer
> MindIQ Corporation
Chris Smith - 10 Jun 2005 14:35 GMT
> OK If  I have <input type="Submit" name="AddProduct" value="Add Product">
> Is the name "AddProduct" automatically sent to the server when the button is
> pressed or do I need to do something else with the name first?

Nope, that's all you need to do.  One of the form parameters will then
have a name of "AddProduct" and a value of "Add Product", if that button
is used to submit the form.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Johan Poppe - 10 Jun 2005 14:38 GMT
Kevin Robinson wrote:

>OK If  I have <input type="Submit" name="AddProduct" value="Add Product">
>Is the name "AddProduct" automatically sent to the server when the button is
>pressed or do I need to do something else with the name first?

The browser sends a parameter with the name "AddProduct" and the value
"Add Product".

If another button is pressed, you'll get something else. For example,
if the user clicks a button defined with <input type="Submit"
name="RemProduct" value="Remove Product">, you will get no parameter
named AddProduct parameter, but instead you'll get a parameter named
RemProduct with the value "Remove Product"..

If you are in doubt of what parameters you actually get, it's easy to
write a testing servlet that simply echos all parameters, or write
them to a servel log or something.

Signature

 Johan Utne Poppe



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.