Jsp Tutorial Home

Jsp Home

JSP Resources

Community

Site

The user can also use the html forms to accept the username and password. This helps to establish the application level or module level security in web world. All sites follow the different security policies and standards. It is always better to use the application managed security for better results. Also, when the application is moved to some other servers then it hardly impacts the application managed security. The following example will demonstrate a form and shows the welcome message if user enters the correct username and password.


Example:-


<% String action= request.getParameter("action");
if(action != null && action.equals("submit")){
    String username=request.getParameter("username");
    String password=request.getParameter("password");
if(username != null && password != null && username.equals("visualbuilder") && password.equals("test"))
{
  out.println("<h3>welcome to the page</h3>");
}else{
  out.println("<h3>Wrong password!!!!</h3>");
}
}else{
%>


<html>
<form action="formsecurity.jsp" method="post">
  <input type="hidden" name="action" value="submit">
  Enter the user name :- <input type="text" name="username" ><br>
  Enter the password :- <input type="password" name="password" ><br>
  <input type="submit" name="submit" value="submit">
</form>
</html>
<%
}%>


Output:-



                    

Copyright © 2013 VisualBuilder. All rights reserved