Professional Documents
Culture Documents
Anuj Balmiki CJ Prac.11
Anuj Balmiki CJ Prac.11
<div style="width: 300px; height: 100px; background: red; padding: 10px; padding-top: 60px; border-radius: 20px;
background: rgb(34,193,195);
background: radial-gradient(circle, rgba(34,193,195,1) 0%, rgba(45,253,110,1) 100%);
margin-left: 220px">
<form action="Page1.jsp" method="post">
Enter the number: <input type="number" name="number"><br>
<input type="submit" value="Submit"><br>
</form>
</div>
</body>
</html>
Code:
Page1.jsp
<%--
Document : page1.jsp
Created on : Sep 18, 2021, 3:11:50 PM
Author : Anuj
--%>
</body>
</html>
Output:
Practical: 11 b & c
Aim:
b. intrinsic objects of various types. Develop a simple JSP application to pass values from
one page to another with
c. Create a registration and login JSP application to register and authenticate the
Code:
User_input.html
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>User Input</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div style="width: 300px; height: 150px; background: red; padding-left: 20px; padding-top: 5px;border-radius: 20px;
background: rgb(34,193,195);
background: radial-gradient(circle, rgba(34,193,195,1) 0%, rgba(45,253,110,1) 100%);
margin-left: 220px; margin-top: 120px">
<h4 style="height: 5px">Enter Username & Password</h4>
<form action="authenticate.jsp" method="post">
<input type="text" name="u_nm"><br>
<input type="text" name="u_ps"><br>
<input type="submit" value="Submit"><br>
</form>
<a href="register.html">Register</a>
</div>
</body>
</html>
authenticate.jsp:
<%--
Document : authenticate
Created on : Sep 20, 2021, 12:27:20 PM
Author : Anuj
--%>
<%@page import="java.sql.*"%>
Boolean found=false;
String user=null;
while(rs.next()){
if(rs.getString(2).equals(uname) && rs.getString(3).equals(upass)){
found=true;
user=rs.getString(1);
break;
}
}
if(found){
out.println("Welcome "+user);
}
else{
out.println("Invalid User");
}
}
catch(Exception e){
out.println(e);
}
%>
</div>
</body>
</html>
Output:
register.html:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Register</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div style="width: 300px; height: 200px; background: red; padding: 10px;border-radius: 20px;
background: rgb(34,193,195);
background: radial-gradient(circle, rgba(34,193,195,1) 0%, rgba(45,253,110,1) 100%);
margin-left: 220px; margin-top: 100px">
<h1 style="height: 5px">Register</h1><br>
<form action="register.jsp" method="post">
Name: <input type="text" name="nm"><br>
User Name: <input type="text" name="u_nm"><br>
Password: <input type="text" name="u_ps"><br>
<input type="submit" value="Register"><br>
<input type="reset" value="Clear"><br>
</form>
</div>
</body>
</html>
register.jsp:
<%--
Document : register
Created on : Sep 21, 2021, 9:14:18 AM
Author : Anuj
--%>
<%@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>
<div style="width: 250px; height: 100px; background: red; padding-left: 100px; padding-top: 70px; border-radius: 20px;
background: rgb(34,193,195);
background: radial-gradient(circle, rgba(34,193,195,1) 0%, rgba(45,253,110,1) 100%);
margin-left: 220px; margin-top: 120px">
<%
try{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/anuj","root","");
//out.println("Connection done");
int a=ps.executeUpdate();
out.println(a+" Records Inserted");
}catch(Exception e){
out.println(e);
}
%>
</div>
</body>
</html>
Output: