WTL P6
WTL P6
Program:
Index.html Page:
<html>
<head>
<title>Start</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center><h1 style="background-color:MediumSeaGreen;">Welcome To Sinhgad Academy
Of Engineering</h1></center><br><br>
<a href="Signin.html"><center><input type="button" value="Login"
style="width:160px;font- size:20pt;color:black; background-
color:MediumSeaGreen;"></center></a>
<br>
<a href="registration.html"><center><h2><input type="button"
value="Registration" style="width:160px;font-size:20pt;color:black; background-
color:MediumSeaGreen;"></h2></center></a>
<br><br>
</body>
</html>
Sinhagad.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> artment of
Computer Engineering, SAE, Kondawa Page 41 <title>Sign In JSP</title>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
</head>
<body>
<%
String user=request.getParameter("username");
String pword=request.getParameter("password");
Try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stud",
"root", "");
String sql="select * from reg where username=? and password=?";
PreparedStatement pst=conn.prepareStatement(sql); pst.setString(1, user);
pst.setString(2,pword);
ResultSet rs=pst.executeQuery();
if(rs.next())
{
%>
<jsp:forward page="home.jsp"/>
<%
} else
{
%>
<jsp:forward page="Signin.html"/>
<%
}
}
catch(Exception e){
System.out.println(e);
}
%>
</body>
</html>
Signin.html
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="Signin.jsp" id="std" method="POST" >
<center>Username : <input type="text" name="username" id="user"
style="width:200px;font- size:15pt;" ><br><br></center>
<center>Password : <input type="password" name="password"
id="pass" style="width:200px;font- size:15pt;" ></center><br>
<center><input type="submit" name="login" value="Login" id="sub"
style="width:160px;font- size:20pt;color:black; background-
color:grey;">    
<input type="reset" value="Reset"
style="width:160px;height:38px;fontsize:20pt;color:black; background-
color:grey;"></center>
</form>
</body>
</html>
Omg.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Student Information</title>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
</style>
</head>
<body style="font-family:Veranda,sans-serif;">
<center>
<div class="header">Student Information</div>
<br><br><br>
<%
try{ Class.forName("com.mysql.jdbc.Driver"
);
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stud",
"root", "");
String sql="select * from info";
PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery();
out.print("<table border=3px solid red>");
//width=\"100%\">
out.print("<tr style=\"background-color:#ff5b5b;color:white;\">");
out.print("<th colspan=\"5\">C3 Student Information</th>");
out.print("</tr>"); out.print("<tr>"); out.print("<t h>Name<\t>");
out.print("<th>Address</th>"); out.print("</tr>"); while(rs.next())
{
out.print("<tr>"); out.print("<td>"); out.print(rs.getString("name"); out.print("</t");
out.print("<td>"); out.print(rs.getString("address"));
out.print("</td>";out.print("</tr>");
}
}
catch(Exception
e)
{
System.out.println(e);
}
%>
<hr/>
<% %>
<a href="index.html" style="hover:green;"><button class="button
logout">Logout</button></a>
<hr/>
</body>
</html>
registration.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>Sign Up JSP</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
<%
String name=request.getParameter("name");
String gender=request.getParameter("gender"); String email=request.getParameter("email");
String college=request.getParameter("college"); String
branch=request.getParameter("branch"); String mobile=request.getParameter("mobile");
String username=request.getParameter("username"); String
pass=request.getParameter("password");
System.out.println(name); try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stud",
"root", "");
String sql="insert into reg(name,gender,email,college,branch,mobile,username,password)
values(?,?,?,?,?,?,?,?)";
PreparedStatement pst=conn.prepareStatement(sql); pst.setString(1,
name); pst.setString(2, gender); pst.setString(3, email); pst.setString(4,
college); pst.setString(5, branch); pst.setString(6, mobile);
pst.setString(7, username); pst.setString(8, pass) pst.executeUpdate();
%>
alert('Registered Successfully!');
<jsp:forward page="Signin.html"/>
<%
}
catch(Exception
e)
{
System.out.println(e);
}
%>
</body>
</html>
registration.html
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
</head>
<body>
<center><h1 style="background-color:Tomato;">Student Registration</h1></center>
<hr />
<br>
<form id="fr" action="registration.jsp" method="POST">
<br>
<center> Name* :    <input type="text" name="name" id="name"
placeholder="Enter name" style="width:200px;font-size:12pt;color:black; " ></center>
<br><br>
<center>Gender Type*:   <input type="radio" name="gender" value="male"
>Male      
<input type="radio" name="gender" value="female" >Female </center><br><br>
<center>Email id *:  <input type="text" name="email" id="email"
placeholder="Enter email" style="width:200px;font-size:12pt;color:black;" ></center>
<br><br>
<center>College *:   <input type="text" name="college" id="college"
placeholder="Enter College" style="width:200px;font-size:12pt;color:black;" ></center>
<br><br>
<center>Branch *:   <input type="text" name="branch" id="branch"
placeholder="Enter Branch" style="width:200px;font-size:12pt;color:black;" ></center>
<br><br>
<center>Mobile No *:<input type="text" name="mobile" id="mobile" placeholder="Enter
Mobile no" style="width:200px;font-size:12pt;color:black;" ></center>
<br><br>
<center>Username *: <input type="text" name="username" id="username"
placeholder="Enter username" style="width:200px;font-size:12pt;" ><br><br></center>
<center>Password *: <input type="password" name="password" id="password"
placeholder="Enter Password" style="width:200px;font-size:12pt;" ></center><br>
<center><input type="submit" value="Submit"
style="width:100px;fontsize:15pt;color:black; background-color:blue;" > 
   
<input type="reset" value="Reset" style="width:100px;font-size:15pt;color:black;
background- color:blue;"></center>
<br><br>
<hr />
<center><p style="font-size:15pt;color:black;">(*) Field indicates field is
mandatory!!</p></center>
</form>
</body>
</html>