*Static Database
*FileName.
-Index.html : For UserName & Password.
-Process.jsp: For Static Database.
-Welcome.jsp :Welcome File
*Code
Index.html
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="servlet.jsp" method="post">
Enter your UserName:<input type="text" name="name"><br>
Enter your Password:<input type="password" name="pas"><br>
Enter your email:<input type="email" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="wel.jsp" method="post">
Name:<input type="text" name="name"><br>
password:<input type="password" name="pas"><br>
<input type="submit">
</form>
</body>
</html>
*Wel.jsp
<%@page import="java.io.*"%>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String name=request.getParameter("name");
String pass=request.getParameter("pas");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/phgraph","root","ujash7878");
PreparedStatement ps=con.prepareStatement("select * from reg where name=? and pas=?");
ps.setString(1, name);
ps.setString(2, pass);
ResultSet rs=ps.executeQuery();
if(rs.next())
{
out.println("<h1>Welcome :"+name+"</h1>");
}
else
{
out.println("<h1>Not Done</h1>");
}
%>
</body>
</html>
*OUTPUT
*FileName.
-Index.html : For UserName & Password.
-Process.jsp: For Static Database.
-Welcome.jsp :Welcome File
*Code
Index.html
<head>
<title></title>
<meta
http-equiv="Content-Type" content="text/html;
charset=UTF-8">
</head>
<body>
<form action="Process.jsp"
method="post">
Username:<input
type="text" name="uname">
password:<input
type="password" name="pass">
<input type="submit">
</form>
</body>
</html>
Process.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
String a=request.getParameter("uname");
String b=request.getParameter("pass");
<!DOCTYPE html>
<%
String a=request.getParameter("uname");
String b=request.getParameter("pass");
if(a.equals("queue") && b.equals("queue"))
{
{
response.sendRedirect("Welcome.jsp");
}
%>
}
%>
Welcome.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
out.println("Welcome to world of jsp");
%>
<!DOCTYPE html>
<%
out.println("Welcome to world of jsp");
%>
*Output
*Dynamic Database
*FileName
-index.jsp :For Register Form.
-servlet.jsp: Insert data indata base & redirect page login.jsp
-login.jsp : Make sure Login Data.
-wel.jsp:Welcome File.
*Code
*index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="servlet.jsp" method="post">
Enter your UserName:<input type="text" name="name"><br>
Enter your Password:<input type="password" name="pas"><br>
Enter your email:<input type="email" name="email"><br>
<input type="submit">
</form>
</body>
</html>
*servlet.jsp
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%
String name=request.getParameter("name");
String pass=request.getParameter("pas");
String email=request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/phgraph","root","ujash7878");
PreparedStatement ps=con.prepareStatement("insert into reg values(?,?,?)");
ps.setString(1,name);
ps.setString(2, pass);
ps.setString(3, email);
int i=ps.executeUpdate();
if(i>0)
{
response.sendRedirect("login.jsp");
}
else
{
out.println("Try Again");
}
%>
</head>
<body>
</body>
</html>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%
String name=request.getParameter("name");
String pass=request.getParameter("pas");
String email=request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/phgraph","root","ujash7878");
PreparedStatement ps=con.prepareStatement("insert into reg values(?,?,?)");
ps.setString(1,name);
ps.setString(2, pass);
ps.setString(3, email);
int i=ps.executeUpdate();
if(i>0)
{
response.sendRedirect("login.jsp");
}
else
{
out.println("Try Again");
}
%>
</head>
<body>
</body>
</html>
*login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="wel.jsp" method="post">
Name:<input type="text" name="name"><br>
password:<input type="password" name="pas"><br>
<input type="submit">
</form>
</body>
</html>
*Wel.jsp
<%@page import="java.io.*"%>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String name=request.getParameter("name");
String pass=request.getParameter("pas");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/phgraph","root","ujash7878");
PreparedStatement ps=con.prepareStatement("select * from reg where name=? and pas=?");
ps.setString(1, name);
ps.setString(2, pass);
ResultSet rs=ps.executeQuery();
if(rs.next())
{
out.println("<h1>Welcome :"+name+"</h1>");
}
else
{
out.println("<h1>Not Done</h1>");
}
%>
</body>
</html>
*OUTPUT
Thanks ;)
Happy Coding.
IPVA 2019 consulte agora.
ReplyDeleteAs we know there are many companies which are converting into Big data service providers. with the right direction we can definitely predict the future.
ReplyDeletepunccomstitha Cody Bou https://wakelet.com/wake/G1jOuLQytkwHLAW6pk9MS
ReplyDeletesteatlomolin
NgranadKdistke-Minneapolis Hector Buoy https://www.leedunnesoccer.com/profile/jaynelezylinafairlee/profile
ReplyDeletepostcarczines
Useful Information, your blog is sharing unique information...Thanks for sharing!!!
ReplyDelete1Z0-900: Java EE 7 Application Developer
agflecdeomo Natasha Miller link
ReplyDeletedownload
link
https://colab.research.google.com/drive/1uTAsHe4su1HRoqfRB_OwJAbRdfv_xPs1
giobroningui
paltemKgin-me Joe Bonsness software
ReplyDeleteclick here
icdedere