Customizing the login.jsp

About this task

You can customize the login.jsp page to accept additional inputs from the user in the Sign In screen. By default, the Sign In screen accepts two fields, user name and password. After adding the required additional fields, you can validate or authenticate the newly added fields.

To customize the login.jsp:

Procedure

  1. To accept the additional fields during login, edit the logininputs.jsp file and add the required additional fields after the user name and password field definitions.
  2. To validate or authenticate the newly added fields, in your custom PostAuthentication class, implement the doPostAuthenticate() method of the IYFSPostAuthentication interface. The doPostAuthenticate() method takes the HttpServletRequest object as a parameter, through which you can access the additional fields from the logininputs.jsp. Errors, if any, should be wrapped in APIManager.XMLExceptionWrapper exception and thrown from this method. If there are no errors, the doPostAuthenticate() method returns True.

    By default, the HTML UI framework authenticates the user name and password. If the user name or password fails, a "Login Failed" message is displayed. In the same way, if the additional field authentication fails, a "Login Failed" message is displayed. However, if the post authentication class is unavailable, "Application error, please contact administrator" is displayed.

  3. In the application's config.xml file, add the <Context-Params> tag and under the <Context-Params> tag add the <Context-Param> tag for defining the parameter names of the PostAuthentication class. For example,
    <WebComponents>  
    				 <ContextParams>  
    				      <Context-Param>  
                <Param-Name> PostAuthenticationClass</Param-Name> 
    				        <Param-Value>com.yantra.platformdemo.ui.backend.ClientPostAuthClass  
    				        </Param-Value> 
    				      </Context-Param> 
    				  </ContextParams>  
    				</WebComponents>