नमस्ते

While working on Net-Centric Project I came across an obstacle of creating multiple buttons and calling different servlets within the same form. This was in the login page, where we can either login or register by making use of the same form fields ‘username’ and ‘password’.

To do so you can create a button as following:

<input type="submit" id="reg" value="Register" onclick="form.action='registerServlet';">

This would call another Servlet when this button is clicked.

The form will look something like this:

<form method="post" action="loginServlet">
  <input type="text" name="username" value="Username" autofocus >
  <input type="password" name="password" value="Password" >
  <input id="login" type="submit" value="Login" >
  <input type="submit" id="reg" value="Register" onclick="form.action='registerServlet';">
</form>

Happy coding.

Let the Windows be open, and feel the Freedom.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s