Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Servlets

 
Anuradha Men
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends
I have two buttons on a html form (Add for adding data from into DB, Edit to retrive data from DB.) I have written two servlets for two separate functions (Adding and Editing)
I want to know how to invoke these two servlets in single htmlform coz' both the buttons are on the same form & we have the format:
<form name="FF" action="http://local host:8080/servlet/servletname" method=Post>
How to do this .
Pls reply.
Bye
Anuuu
 
KASI VISHWANATH
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use location.replace for different button or send a parameter like editing etc
------------------
I.K.VISHWANATH
 
lokesh reddy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anu,
Here is the solution for ur problem.
<html>
<head>
<title>Testing</title>
<script language="JavaScript">
function setaction(thefield)
{
if(thefield=="file2")
{
document.temp.action="http://hostname/servletname";
document.temp.submit();
}
if(thefield=="file3")
{
document.temp.action="http://hostname/servletname";
document.temp.submit();
}
}
</script>
</head>
<body>
<form name="temp" method=post>
<input type=button name="file2" value="file2" onClick="setaction(this.name)">
<input type=button name="file3" value="file3" onClick="setaction(this.name)">
</form>
</body>
</html>
Replace the hostname and the servlet name with appropriate names.I tested this piece of code and its working fine.
I hope this info may be useful to you.
Bye.
Loke.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic