• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invoking 2 servlets in the same html page

 
Jenna Thomas
Greenhorn
Posts: 27
  • 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
Greenhorn
Posts: 27
  • 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>
 
Bryan Basham
author
Ranch Hand
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
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bryan!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic