Web Design and Web Development Forum

  1. #1
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0
  2. lantocs is on a distinguished road
  3. login page in jsp

    Logindemo.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <center>
    <form action="sucess.jsp" method="post" >
    <table border="15" bgcolor="gray">
    <tr>
    <td>First Name:
    <input type="text" name="fname" size="40" maxlength="40" >
    </td>
    </tr>
    <tr>
    <td>Last Name:
    <input type="text" name="lname" size="40" maxlength="40" ><br>
    <center>
    <input type="Submit" Value="submit" >
    <input type="Reset" Value="reset" >
    </center>
    </td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>

    success.jsp

    <%@ page language="java" import="javaBeandemo.LoginBean.*,java.io.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <center>
    <jsp:useBean id="LoginBean" class="javaBeandemo.LoginBean" scope="request"></jsp:useBean>
    <jsp:setProperty name="LoginBean" property="*"/>
    <%
    if(LoginBean.isValidUser())
    {
    %>
    Login Successful!<br>
    Welcome!
    <%
    }
    else
    {
    %>
    User Not Found <br><br>
    <a href="Beanloginpage.jsp">Try Again</a>
    <%
    }
    %>
    </center>

    </body>
    </html>

    LoginBean

    public class LoginBean {

    private String Firstname="";
    private String Lastname="";

    public LoginBean()
    {

    }
    public String getFirstname()
    {
    return Firstname;
    }

    public void setFirstname(String Firstname)
    {
    this.Firstname=Firstname;
    }
    public String getLastname()
    {
    return Lastname;
    }

    public void setgetLastname(String getLastname)
    {
    this.Lastname=Lastname;
    }
    public boolean isValidUser()
    {
    if(Firstname.equals(Lastname))// && Lastname.equals("raj"))
    {
    System.out.println("login success");
    }else
    {
    System.out.println("login failed");
    }
    return true;
    }
    }
    Reply With Quote Reply With Quote
  4. #2
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0
  5. johnagan56 is on a distinguished road
  6. Re: login page in jsp

    I am new to this forum and glad to be a part of this. i hope that i can learn more and share my ideas and thoughts as well. Thanks for posting such a post.

    Web Design
    Reply With Quote Reply With Quote

Similar Threads

  1. Remote login to an aspx page
    By Mojtaba_g79 in forum PHP Scripting
    Replies: 2
    Last Post: 01-01-2010, 10:43 PM
  2. phpmyadmin login page
    By hendy in forum PHP Scripting
    Replies: 2
    Last Post: 07-10-2008, 09:37 PM
  3. call a page onUnload page
    By hendy in forum JavaScript Coding
    Replies: 8
    Last Post: 04-08-2008, 09:32 PM
  4. Replies: 5
    Last Post: 06-08-2006, 09:29 PM
  5. IPB - Login Help :)
    By Shinitenshi in forum PHP Scripting
    Replies: 5
    Last Post: 05-26-2006, 10:39 PM