|  Home   |  Contact Us   |  Online Exam   |  Tech World   |  Jobs    |  Member Login
Java Interview Questions
Jdbc Interview Questions
Servlet Interview Questions
Jsp Interview Questions
Struts Interview Questions
Ajax Interview Questions
Webservice Interview Questions
Designpattern Interview Questions
J2me Interview Questions
EJB Interview Questions
Spring Interview Questions
Hibernet Interview Questions
Enterprise IT Training
Java Program Examples
Ask Technical Expert!
Write Online Exam and Get Job Opportunity Here!
        JSP Examples          
Steps to Execute Jsp  |   Module 1  |   Module 2  |   Module 3  |  

Step 1: Design code for Login Page
      <html>
     <head>
     <title>userloginpage</title>
     <SCRIPT LANGUAGE="javascript"> function usermeth()
     {
     var user=document.Login_Page.usr.value;
     var pass=document.Login_Page.pswd.value;
     if(user.length==0) { alert("Please Enter the username");
     document.Login_Page.usr.focus(); return false;
     }
     if(pass.length==0){ alert("Please Enter the password");
     document.Login_Page.pswd.focus(); return false;
     } return true;
     }
     </script></head><body>
     <form name="Login_Page" method="Post" action="loginjsp.jsp"
     onsubmit="javascript: return usermeth()">
     <center><font color='green' size=4>Login your Authentication:</font><br><br>
     Enter UserName<input type="text" name="usr">
     <br>
     Enter PassWord<input type="password" name="pswd"><br>
     <input type="submit" value="`````Submit`````">
     </center>
     </form>
     </body>
     </html>

Step 2: Design code for Access values from DB
      <%@ page import="java.sql.*" %>
     <html>
     <head>
     <title>LoginJSP</title>
     </head>
     <body>
     <form>
     <%
     String username=request.getParameter("usr");
     String password=request.getParameter("pswd");
     String sql="select * from logintb";
     Connection con;
     ResultSet rs;
     try
     {
     Class.forName("com.mysql.jdbc.Driver");
     }
     catch(ClassNotFoundException e)
     {
     System.out.println("Class Error");
     }
     try
     {
     con=DriverManager.getConnection("jdbc:mysql://localhost:3306/vijikumar","root","sun");
     Statement st = con.createStatement();
     rs=st.executeQuery(sql);
      while(rs.next())
     {
     String us=rs.getString(1);
     String ps=rs.getString(2);
     if(us.equals(username)&&ps.equals(password))
     {
     %>
     <jsp:forward page="logsuc.html"/>;
     <%
     }
     else
     { %>
     <jsp:forward page="logfail.html"/>;
     <% }
     }
     }
     catch(SQLException e)
     {
     System.out.println(e.getMessage());
     }
     %>
     </form>
     </body>
     </html>
Step 3: Design code for If the output of success page
      <head>
      <title>LoginSucess</title>
      </head>
      <body>
      <h2><Font color="green">LoginSuccessfully</Font></h2>
      </body>
      </html>
Step 4: Design code for If the output of failurepage
<html>
     <head>
     <title>LoginFailed</title>
     </head>
     <body>
     <h2><Font color="red">LoginFailed</Font></h2>
     </body>
     </html>
Back to Top
All Rights Reserved : skdotcom technologies