dcsimg
October 16, 2018
Hot Topics:

Java Tip: Spice Up Your GlassFish Authentication Form

  • March 4, 2011
  • By Anghel Leonard
  • Send Email »
  • More Articles »

Usually when you develop a GlassFish-based authentication form, you assume that the action should be j_security_check and the fields are j_username and j_password. Knowing that, you can write an HTML form like this:

<form method="POST" action="j_security_check">
    Username: <input type="text" name="j_username" />
    Password: <input type="password" name="j_password" />
    <input type="submit" value="Login" />
</form>

You can spice up this form using JSF code like this:

<form method="POST" action="j_security_check">
    <h:outputLabel for="j_username">Username:</h:outputLabel>
    <h:inputText id="j_username" required="true" />
    <h:message for="j_username" />    
    <h:outputLabel for="j_password">Password:</h:outputLabel>
    <h:inputSecret id="j_password" required="true" />
    <h:message for="j_password" />
    <h:commandButton value="Login" />
</form>

Or, you can take advantage of cool PrimeFaces themes by writing the form like this:

<form method="POST" action="j_security_check">
     <h:outputLabel for="j_username">Username:</h:outputLabel>
     <p:inputText id="j_username" required="true" value="" />
     <h:outputLabel for="j_password">Password:</h:outputLabel>
     <p:password id="j_password" required="true" value="" feedback="false" minLength="0" />
     <h:commandButton value="Login" type="submit" />
</form>


Originally published on https://www.developer.com.


Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

Thanks for your registration, follow us on our social networks to keep up-to-date