tags:

views:

19

answers:

2

I need to design a page to register as well as login a user.By clicking login button login servlet should be called.And on clicking register button,register servlet will be called.how can i do this?

+2  A: 
  1. Having two forms that post to different places is the simplest method

  2. Name your buttons:

    <input type="submit" name="form_action" value="Login" />
    

    and

    <input type="submit" name="form_action" value="Register" />
    

    When it comes to processing the form, just hookout form_action and it should equal Login or Register.

    This requires some more server-side logic but should work if you need your two forms to be tightly combined.

Oli
Thanks for your help
bhavna raghuvanshi
A: 

You can include some Javascript code for this.

<form name="Form1" method="post">

Your Name <input type="text" name="text1" size="10" /><br />

<INPUT type="button" value="ButtonLogin" name=button1 onclick="return OnButtonLogin();">
<INPUT type="button" value="ButtonRegister" name=button2 onclick="return OnButtonRegister();">

</form>

like this:

<script language="Javascript">
<!--
function OnButtonLogin()
{
    document.Form1.action = "Login.do"
    document.Form1.target = "_blank";    
    document.Form1.submit();             
    return true;
}

function OnButtonRegister()
{
    document.Form1.action = "Register.do"
    document.Form1.target = "_blank";    
    document.Form1.submit();             
    return true;
}
-->
</script>
bdhar
i am not using java script.anywats thanks.
bhavna raghuvanshi