Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Create a form-based login page is very easy and only you have to follow some important considerations.

You can create a login page in an HTML page, JSP page or Servlet and the basic code Rather than build a login page based on SmartClient or SmartGWT components, we recommend using a plain HTML login page.  This is because a plain HTML login page provides better interoperability with other technology (such as single sign-on systems), will load faster, and provides an opportunity to pre-load application resources while the user types credentials.  This is discussed in more detail in the Data Integration chapter of the QuickStart Guide.

This article shows a simple example of login screen that works with the form-based authentication systems provided by typical servlet engines such as Tomcat and JBoss. The basic HTML code for your login form should be:

Code Block
langhtml
<form method="POST" action="j_security_check">
    <input type="text" name="j_username">
    <input type="password" name="j_password">
</form>
 

Here the important considerations are:

1.- The name of the field of username always be named username field is named j_username.2.- The name of the field of password always be  and password is named j_password.  These are typical default field names for many different Java authentication systems.

32.- The action of the login form must be is typically j_security_check.

These considerations are very important for that the authentication mechanism correctly works.

Last, comment that you can create If authentication fails, most authentication systems allow you to provide an error page as well, because if the authentication fails, the user will be redirected to this page.Next, some screenshots of this example:the example code available below includes this as well.

You can download a sample login page and error page below.  This includes a login form like the above, with some simple CSS styling to center the form under a background logo.


The source code of this example , you can download it is available here.