• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Passing values from forms..

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm relatively new to JSP and HTML..i wud like to know how can i pass the values entered in two different forms on a single page to a servlet which is invoked...`
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to my understanding, you have 2 forms in a jsp page. But I want to know, do those forms refer to a servlet?
If those forms refer to a servlet, i think you can only have one form instead of two form.
If those forms do not refer to a servlet, you can just fill the name of servlet in action field ( attribute of FORM tag) for each form....
Correct me if i am wrong...
daniel
 
Sheriff
Posts: 67752
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
Firstly, if you need to have the union of the controls in the two forms sent to a single action (in this case your servlet), I'd step back from the code for a second and re-evaluate why you have the controls in two separate forms in the first place.
If you come to the conclusion that you have a really good reason for having the two separate forms, there are a number of tactics you can use.
The simplest would be to have the first form contain hidden field controls that mirror the visible controls in the second form. Upon form submission, the values in the visible form fields (in the 2nd form) can be copied via JavaScript to the hidden fields in the first form and thus be submitted to the servlet along with the fields of the first form.
But again, I'd urge you to reflect on your design before putting this kind of mechanism in place to see if it is really necessary in the first place.
hth,
bear
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic