Output of Build Project
:
Selecting the Default Browser for Server
:
Click on Globe Icon---->List of Browsers Opened--->Choose Chrome Browser
Creating a new JSP File
:
Right Click on WebPages--->Select New
Under JsP file window----->Choose a File Name---->Click On Next
JSP Projects with Source Code
:
ALTER procedure [dbo].[sp_adduserdata]
(
@name varchar(100),
@uname varchar(100),
@pwd varchar(100)
)
as begin
--- database validation
insert into tbl_user(name, uname,pwd)
values(@name,@uname,@pwd)
end
ALTER procedure [dbo].[sp_getuserdata]
as begin
select * from tbl_user
end
ALTER procedure [dbo].[sp_loginuser]
(
@uname varchar(100),
@pwd varchar(100)
)
as begin
select name from tbl_user
where uname = @uname and pwd=@pwd
end
ALTER procedure [dbo].[sp_searchuserdata]
(
@searchdata varchar(100)
)
as begin
select * from tbl_user where uname like '%'+@searchdata+'%'
end
try{
PreparedStatement pst = null;
if(request.getParameter("submit")!=null)
{
String login = request.getParameter("login");
String pwd = request.getParameter("pwd");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;"+ "databaseName=bottle_manufacturing_March-23;"+
"TrustServerCertificate=True;user=aaa;password=aaa");
String sql = "exec sp_loginuser ?,?";
pst = con.prepareStatement(sql);
pst.setString(1, login);
pst.setString(2, pwd);
ResultSet rs= pst.executeQuery();
if (rs.next()) ///fetch the data from the result set
{
String loggedinUser=rs.getString("name");
if(loggedinUser != null){
%>
<script>alert("Valid user. Welcome");</script>
<%
response.sendRedirect("Dashboard.jsp?user="+loggedinUser);
session.setAttribute("user1",loggedinUser);
}
else{
%>
<script>alert("Invalid user. Problem Login");</script>
<%}
}
else
{
%>
<script>alert("Invalid user. Problem Login")</script>
<%
}
}
}//end of try
catch(Exception e){
%>
<script>alert("Invalid User. Problem in Login")</script>
<%
}//end of catch
%>
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS-BootStrap Link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -BootStrap Link-->
<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Kaashiv Infotech Login Page!</h1>
<div class="container">
<h2>Login Page</h2>
<div class="col-sm-4">
<form method="POST" action="#" >
<div class="row">
<label class="form-label">Login Name</label>
<input type="text" class="form-control" placeholder="Login Name"
name="login" id="login" required >
</div>
<div class="row">
<label class="form-label">Password</label>
<input type="text" class="form-control" placeholder="Password"
name="pwd" id="pwd" required >
</div>
<br />
<div class="row">
<input type="submit" id="submit" value="submit"
name="submit" class="btn btn-warning">
</div>
</form>
</div>
</div>
</body>
</html>
New User Registeration Page <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%
try
{
PreparedStatement pst=null; //prepare a statement for execution
if(request.getParameter("submit") != null) //submit button aluthi vitaya ilaya
{
String name = request.getParameter("name");
String login = request.getParameter("login"); // datavai eduthu vidu
String pwd = request.getParameter("pwd"); //pwd text box datavai eduthu vidu
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn= DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;"
+ "databaseName=bottle_manufacturing_March-23;"
+ "TrustServerCertificate=True;user=aaa;password=aaa");
//if it is insert or update or delete... use the command executeUpdate()
int i = pst.executeUpdate();
// Step 4 : Get the result as postive or negative
if (i==1) ///fetch the data from the result set
{
%>
<script> alert("User Added Successfully!!!.Welcome");</script>
<%
response.sendRedirect("Home.jsp");
}
else
{
%>
<script> alert("Problem in adding user.");</script>
<%
}
}
}//end of try block
catch(Exception ex)
{
%>
<script> alert("Problem in adding user.")</script>
<%
}
%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>New User Page</h1>
<div class="container">
<h2>Login Page</h2>
<div class="col-sm-4">
<form method="POST" action="#" >
<div class="row">
<label class="form-label">Name</label>
<input type="text" class="form-control" placeholder="Name" name="name" id="name" required >
</div>
<div class="row">
<label class="form-label">Login Name</label>
<input type="text" class="form-control" placeholder="Login Name" name="login" id="login" required >
</div>
<div class="row">
<label class="form-label">Password</label>
<input type="text" class="form-control" placeholder="Password" name="pwd" id="pwd" required >
</div>
<br />
<div class="row">
<input type="submit" id="submit" value="submit" name="submit" class="btn btn-warning">
</div>
</form>
</div>
</div>
</body>
</html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css" >
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.min.js" ></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dashboard Page</title>
</head>
<body>
<div class="container">
<h2>Dashboard Page</h2>
<div class="col-sm-4">
<% String name=(String)session.getAttribute("user1"); %>
<h2>Hello <%=name %></h2>
<div class="row">
<a href="SearchData.jsp">Search Data</a>
</div>
<form method="POST" action="#" >
<div class="row">
<input type="submit" id="submit" value="submit" name="submit" class="btn btn-warning">
</div>
<table class="table table-borderless table-dark">
<thead>
<tr>
<th scope="col">#id</th>
<th scope="col">Name</th>
<th scope="col">uname</th>
<th scope="col">pwd</th>
</tr>
</thead>
<tbody>
<%
PreparedStatement pst=null; //prepare a statement for execution
if(request.getParameter("submit") != null) //submit button aluthi vitaya ilaya
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn= DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;"
+ "databaseName=bottle_manufacturing_March-23;"
+ "TrustServerCertificate=True;user=aaa;password=aaa");
String sql = "exec sp_getuserdata";
pst = conn.prepareStatement(sql);
ResultSet rs= pst.executeQuery();
while (rs.next())
{
%>
<tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("uname")%></td>
<td><%=rs.getString("pwd")%></td>
</tr>
<%
}
}
%>
</tbody>
</table>
</form>
</div><!-- comment -->
</div>
</body>
</html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.min.js" ></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Search Data Page</title>
</head>
<body>
<div class="container">
<h2>Dashboard Page</h2>
<div class="col-sm-4">
<% String name=(String)session.getAttribute("user1"); %>
<h2>Hello <%=name %></h2>
<div class="row">
<a href="SearchData.jsp">Search Data</a>
<form method="POST" action="#" >
<div class="row">
<label class="form-label">Search Data</label>
<input type="text" class="form-control" placeholder="Search Data" name="search" id="search" required >
</div>
<div class="row">
<input type="submit" id="submit" value="submit" name="submit" class="btn btn-warning">
</div>
<table class="table table-borderless table-dark">
<thead>
<tr>
<th scope="col">#id</th>
<th scope="col">Name</th>
<th scope="col">uname</th>
<th scope="col">pwd</th>
</tr>
</thead>
<tbody>
<%
PreparedStatement pst=null; //prepare a statement for execution
if(request.getParameter("submit") != null) //submit button aluthi vitaya ilaya
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn= DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;"
+ "databaseName=bottle_manufacturing_March-23;"
+ "TrustServerCertificate=True;user=aaa;password=aaa");
String search = request.getParameter("search");
String sql = "exec sp_searchuserdata ?";
pst = conn.prepareStatement(sql);
pst.setString(1, search);
ResultSet rs= pst.executeQuery();
while (rs.next())
{
%>
<tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("name")%></td>
<td><%=rs.getString("uname")%></td>
<td><%=rs.getString("pwd")%></td>
</tr>
<%
}
}
%>
</tbody>
</table>
</form>
</div><!-- comment -->
</div>
</body>
</html>