File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion 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: 1199
< 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: 61761
    
  67

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: 1199
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: 61761
    
  67

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: 1199
Cool! I never knew that. Thanks, Bear.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

My pleasure!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hidden message?