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:
<form method="POST" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
Here the important considerations are:
- The username field is named j_username and password is named j_password. These are typical default field names for many different Java authentication systems.
- The action of the login form is typically j_security_check.
If authentication fails, most authentication systems allow you to provide an error page, 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 is available here.