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 HTML, CSS and JavaScript and the fly likes Hidden message? 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 » Engineering » HTML, CSS and JavaScript
Bookmark "Hidden message?" Watch "Hidden message?" New topic
Author

Hidden message?

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
< input type='hidden' value='add a new video' name='action' >
< input type='submit' value='add a new video' name='submit' >

I'm working on a Cattle Drive assignment, and part of the given code includes a form with the above buttons. The value of both buttons is the same, but the name is different. I assume that the one named action will be used by an action handler, but I don't understand the need for the hidden button. Wouldn't it be the same if there was one button like so:

< input type='submit' value='add a new video' name='action' >

Could you use the form data submitted by the above button in the same way you could use the data submitted by the pair of buttons above?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

The 'hidden' element is not a button. It acts just like a 'text' input except that it is hidden from view. When the form is submitted, a request parameter named action with the value 'add a new video' will be submitted to the server.

Now, as to whether it's redundant or not depends upon how the server component is written. To me, it looks like all the info needed is available from the submit button.
[ March 24, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Aha! Perhaps then the value submitted by the 'hidden' element would be used to call a method in the servlet I'm supposed to write, and a different value submitted by a 'hidden' element in a different jsp would be used to call a different method. Hmmmm. A clue perhaps.
Would getting the value from the 'hidden' element be done through the use of getParameterValues( "action" ), as it would for a text field?
[ March 24, 2006: Message edited by: Carol Murphy ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Yes. Request parameters are simply a map of name/values pairs. From the point of view of a servlet, or any other server-side mechanism), the type of element (text, hidden, password, dropdown, and so on) that generated the parameter isn't even known.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1194
Cool! I never knew that. Thanks, Bear.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

My pleasure!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hidden message?
 
Similar Threads
Multiple submit buttons with JavaBeans
how to handle mutiple buttons
Dynamically build a form
About Servlet
hidden and submit input types