• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Invoking 2 servlets in the same html page

 
Ranch Hand
Posts: 31
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks Bryan!
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!