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

Invoking 2 servlets in the same html page

 
Ranch Hand
Posts: 31
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to invoke 2 servlets from the same html page
<form method="POST" action="DownloadJar.do">Download at your own risk!
<br>
<center><input type="SUBMIT"></center>


<form method="POST" action="GetInitParams.do">Support Information just in case!
<br><br>
<center><input type="SUBMIT"></center>

But no matter which submit button i press, it always invokes the first servlet.

The second servlet is mapped correctly in the web.xml. I checked.

I was told that we should keep both servlet invocations in the same form. I am not sure how to do that. Can anyone just reply with the skeleton code for that? Servlets newbie by the way. Thanks!
 
Jenna Thomas
Ranch Hand
Posts: 31
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the answer, I hadnt closed the form tags!

So the right code would be
<form method="POST" action="DownloadJar.do">Download at your own risk!
<br>
<center><input type="SUBMIT"></center>
</form>

<form method="POST" action="GetInitParams.do">Support Information just in case!
<br><br>
<center><input type="SUBMIT"></center>
</form>
 
author
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, Jenna, you can invoke a servlet (or JSP) from any HTML tag that takes a URL, such as a link <a href="servlet.do">link text</a> or even a image tag <img src="createMap.do" />.

Cheers,
Bryan
 
Jenna Thomas
Ranch Hand
Posts: 31
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bryan!
 
reply
    Bookmark Topic Watch Topic
  • New Topic