Web Technoly Lab Krishna Kumar
Web Technoly Lab Krishna Kumar
PRACTICAL FILE
COMPUTER SCIENCE AND ENGINEERING
Session (2023-2024)
INDEX
S.No. Name of the Date Page No. Signature of
Experiment Concerned Faculty
1 Write HTML/Java
scripts to display your
CV in navigator, your
Institute website,
Department Website and
Tutorial website for
specific subjects.
2 Write an HTML
program to design an
entry form of student
details and send it to a
database server like
SQL, Oracle or MS
Access.
5 Writing program in
XML for creation of
DTD, which specifies a
set of rules. Create a
style sheet in CSS/ XSL
& display the document
in internet explorer.
6 Program to illustrate
JDBC connectivity.
Program for maintaining
databases by sending
queries. Design and
implement a simple
servlet book query with
the help of JDBC &
SQL.
Create MS Access
Database, Create on
ODBC link, Compile &
execute JAVA JDBC
Socket.
9 Install a database
(MySQL or Oracle).
Create a table which
should contain at least
the following fields:
name, password,
email-id, phone number
Write a java
program/servlet/JSP to
connect to that database
and extract data from the
tables and display them.
Insert the details of the
users who register with
the web site, whenever a
new user clicks the
10 submit button in the
registration page.
Code:
<html>
<head>
<title></title>
</head>
<body>
<div id="header">
<p id="name"><h2>Deep Laxman Sukhwani</h2></p>
<h4><a href="mailto:deepsukhwani@gmail.com"></h4><p
id="email">E-Mail:deepsukhwani@gmail.com</p></a>
</div>
<div class="left">
</div>
<div class="right">
<h3>CV Highlights</h3>
<p>
<ul>
<li>Currently going through CS253 – Web Application Engineering and CS61A
– Structure & Interpretation of Computer Programs</li>
<li>Learnt basic Python, JavaScript, HTML, CSS on Codecademy.com.</li> <li>An
independent, dedicated, efficient person. These attributes are proved through
the series of courses I have taken or I am taking as of now independently through
online platforms.</li>
<li>Good Communication Skills, Presentation Skills, attitude towards leadership,
authorisation and delegation, conflict resolution and negotiation and a very good team
worker.</li></ul>
</p>
<h3>Professional Experience</h3>
<h4 id="company-name">Wingify Software Pvt Ltd</h4>
<p id="job-title"><strong>Support Engineer (Technical
Support)</strong></p> <p id="job-responsibilities">Job Responsbilities</p>
<p>
<ul>
<li>Answer customer queries over email / ticketing system</li>
<li>Interact with our engineering team to get software issues and bugs resolved</li>
<li>Occasionally interact with customers over Skype or telephone</li> <li>Contribute
ideas to the team on how customers can be delighted</li></ul>
</p>
<h3>Educational Qualifications</h3>
<table border=2>
<tr id="heading">
<td>Qualification</td>
<td>University</td>
<td>Percentage / Grades</td>
<td>Year</td>
</tr>
<tr>
<td>S.S.C</td>
<td>Delhi</td>
<td>75.57%</td>
<td>2004</td>
</tr>
<tr>
<td>H.S.C (Mathematics Stream)</td>
<td>Delhi</td>
<td>72.40%</td>
<td>2006</td>
</tr>
<tr>
<td>Graduation</td>
<td>MIET Meerut</td>
<td>A Grade</td>
<td>2010</td>
</tr>
</table>
<h3>Independent Courses</h3>
<p>
<ul>
<li>
<span id="course-name">HTML & CSS for Beginners – Web Fundamentals</span>
</li>
<li>
<span id="course-name">Python – Fundamentals and Data Structure </span>
</li> <li>
<span id="course-name">JavaScript – Programming Basics, JS Apps and Build
Games </span> </li>
<li>
</ul>
<h3>Technical Skills</h3>
<p>
<ul>
<li>
<span id="course-name">Operating Systems:</span> DOS, Windows 8, Windows
10</li>
<li>
<span id="course-name">Application Software:</span> Office 97-2003; Office
XP, Office 2007</li>
<li>
<span id="course-name">Programming Skills:</span>HTML, CSS, Python,
JavaScript, learning C and C++</li></ul>
</p>
<h3>Certifications / Awards:</h3>
<p>
<ul>
<li>AWS Cloud Practitioner Certification in 2008</li>
<li>AWS Solutions Architect Certification in 2009</li>
</ul>
</p>
<h3>Personal Information:</h3>
<p><ul>
<li>Date of Birth: 7/3/1994 </li>
<li>Father's Name: Mr. Rohit Kumar </li>
<li>Category:OBC </li>
<li> Nationality: Indian</li>
<li>Permanent Address:Delhi Road, Meerut U.P.</li>
<li>Communication Address:Delhi Road, Meerut U.P</li>
<li>Mobile No.:123456789 </li>
<li> Email id:abc@gmail.com</li>
<li>
<span id="course-name">Languages Known:</span>English, Hindi, Gujarati and
Sindhi</li>
</p>
<ul>
<h2>Hobbies</h2>
I love reading Finance and IT related books / magazines, playing Chess, swimming,
listening music, surfing Internet, self-learning through e-courses.
</p>
<h3>Other Information</h3>
<p>
<ul>
<li>
<span id="course-name">Expected Salary:</span>As per company standards</li>
<li>
<span id="course-name">Area of Interest:</span>Software Development,
Programming, Start-ups, Coding, App Development, Technical Support, Support
Engineer, Customer Happiness, Client service, </li>
<li>
<span id="course-name">Joining Date:</span>Immediate</li></ul>
</p>
<h3>Declaration</h3>
<p>
I hereby declare that the details furnished above are true and correct to the best of my
knowledge and belief.</p>
</div>
<div id="footer"></div>
</body>
</html>
Output:
Deep Laxman Sukhwani
E-Mail:deepsukhwani@gmail.com
CV Highlights
Professional Experience
▪ Joining Date:Immediate
Declaration
I hereby declare that the details furnished above are true and correct to
the best of my knowledge and belief.
PROGRAM-2
Code:
<html>
<head>
<script type="text/javascript" src="validate.js" ></script>
</head>
<body bgcolor="aqua" bolder="5">
<form action="register.jsp" name="StudentRegistration" method=”post”>
<table cellpadding="2" width="50%" border="10" align="center"cellspacing="2">
<tr>
<td colspan=2>
<center><font size=4><b>Student Registration Form</b></font></center>
</td>
</tr>
<tr>
<td>Name</td>
<td><input type=text name=textnames id="textname" size="30"></td>
</tr>
<tr>
<td>Father Name</td>
<td><input type="text" name="fathername" id="fathername" size="30"></td>
</tr>
<tr>
<td>Postal Address</td>
<td><input type="text" name="paddress" id="paddress" size="30"></td>
</tr>
<tr>
<td>Personal Address</td>
<td><input type="text" name="personaladdress" id="personaladdress" size="30"></td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="sex" value="male" size="10">Male
<input type="radio" name="sex" value="Female" size="10">Female</td>
</tr>
<tr>
<td>City</td>
<td><select name="City">
<option value="-1" selected>select..</option>
<option value="New Delhi">NEW DELHI</option>
<option value="Mumbai">MUMBAI</option>
<option value="Goa">GOA</option>
<option value="Patna">PATNA</option>
</select></td>
</tr>
<tr>
<td>Course</td>
<td><select name="Course">
<option value="-1" selected>select..</option>
<option value="B.Tech">B.TECH</option>
<option value="MCA">MCA</option>
<option value="MBA">MBA</option>
<option value="BCA">BCA</option>
</select></td>
</tr>
<tr>
<td>District</td>
<td><select name="District">
<option value="-1" selected>select..</option>
<option value="Nalanda">NALANDA</option>
<option value="UP">UP</option>
<option value="Goa">GOA</option>
<option value="Patna">PATNA</option>
</select></td>
</tr>
<tr>
<td>State</td>
<td><select Name="State">
<option value="-1" selected>select..</option>
<option value="New Delhi">NEW DELHI</option>
<option value="Mumbai">MUMBAI</option>
<option value="Goa">GOA</option>
<option value="Bihar">BIHAR</option>
</select></td>
</tr>
<tr>
<td>PinCode</td>
<td><input type="text" name="pincode" id="pincode" size="30"></td>
</tr>
<tr>
<td>EmailId</td>
<td><input type="text" name="emailid" id="emailid" size="30"></td>
</tr>
<tr>
<td>DOB</td>
<td><input type="text" name="dob" id="dob" size="30"></td>
</tr>
<tr>
<td>MobileNo</td>
<td><input type="text" name="mobileno" id="mobileno" size="30"></td>
</tr>
<tr>
<td><input type="reset"></td>
<td colspan="2"><input type="submit" value="Submit Form" /></td>
</tr>
</table>
</form><br><br>
<h1><a href="MainPage.html">Back</a></h1>
</body>
</html>
Output
PROGRAM 3
Code:
<html xmlns="http://www.w3.org/1999/xhtml"
> <head runat="server">
<title>Browser Information</title>
<script language=javascript>
function show()
{
document.write("Name "+navigator.appName+"<br>");
document.write("Version "+navigator.appVersion +"<br>");
document.write("Codename " +navigator.appCodeName
+"<br>"); document.write("Cookie
enable"+navigator.cookieEnabled +"<br>");
document.write("Java Enable"+navigator.javaEnabled
+"<br>"); document.write("Mime
type"+navigator.mimeTypes +"<br>");
document.write("Platform"+navigator.platform +"<br>");
document.write("Plug ins"+navigator.plugins +"<br>");
document.write("System
Language"+navigator.systemLanguage +"<br>");
document.write("User language"+navigator.userAgent
+"<br>"); document.write("User
Agent"+navigator.userAgent +"<br>");
</script>
</head>
<body>
<form id="form1">
<div>
<input id="Button1" type="button" value="Click me" onclick="show()" />
</div>
</form>
</body>
</html>
OUTPUT :
PROGRAM 4
Objective: Write a Java applet to display the Application Program screen i.e.
calculator and other.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="Cal" width=300 height=300>
</applet>
*/
Objective: Writing program in XML for creation of DTD, which specifies set of rules.
Create a style sheet in CSS/ XSL & display the document in internet explorer.
<!ELEMENT note
(to,from,heading,body)> <!ELEMENT to
(#PCDATA)> <!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
Code:
1.XML :
XSL:
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Output:
In Internet Explorer
Title Artist
Empire
Bob Dylan
Burlesque
Hide your heart Bonnie Tyler
PROGRAM 6
Theory:
//Display values
System.out.print("ID: " + id);
System.out.print(", Age: " + age);
System.out.print(", First: " + first);
System.out.println(", Last: " + last);
}
//STEP 6: Clean-up
environment rs.close();
stmt.close();
conn.close();
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}// nothing we can do
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}//end try
System.out.println("Goodbye!");
}//end main
}//end FirstExample
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class JDBCServlet extends HttpServlet {
public void doGet(HttpServletRequest
inRequest,
HttpServletResponse outResponse) throws ServletException,
IOException {
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager
.getConnection("jdbc:mysql://localhost/products");
statement = connection.createStatement();
outResponse.setContentType("test/html");
out = outResponse.getWriter();
out.println("<HTML><HEAD><TITLE>Products</TITLE></HEAD>");
out.println("<BODY>");
out.println("<UL>");
while (rs.next()) {
out.println("<LI>" + rs.getString("ID") + " "
+ rs.getString("title") + " " + rs.getString("price"));
}
out.println("</UL>");
out.println("</BODY></HTML>");
} catch (ClassNotFoundException e)
{ out.println("Driver Error");
} catch (SQLException e) {
out.println("SQLException: " +
e.getMessage());
}
}
public void doPost(HttpServletRequest inRequest,
HttpServletResponse outResponse) throws ServletException,
IOException {
doGet(inRequest, outResponse);
}
}
PROGRAM 7
Objective: Install TOMCAT web server and APACHE. Access the above
developed static web pages for books web site, using these servers by putting the
web pages developed .
Theory:
On Windows XP, you could also go to the Start menu, select Control Panel,
chooseSystem, click on the Advanced tab, press the Environment Variables button at
the bottom, and enter the JAVA_HOME variable and value directly as:
Name: JAVA_HOME
Value: C:\jdk
Name: JAVA_HOME
Value: install_dir/common/lib/servlet-api.jar
The next step is to tell Tomcat to check the modification dates of the class files of
requested servlets and reload ones that have changed since they were loaded into
theserver's memory. This slightly degrades performance in deployment situations,
so isturned off by default. However, if you fail to turn it on for your development
server,you'll have to restart the server every time you recompile a servlet that has
already beenloaded into the server's memory.
To turn on servlet reloading, edit install_dir/conf/server.xml and add a
DefaultContext subelement to the main Host element and supply true for the
reloadable attribute. For example, in Tomcat 5.0.27, search for this entry:
<DefaultContext reloadable="true"/>
Be sure to make a backup copy of server.xm before making the above
The invoker servlet lets you run servlets without first making changes to yourWeb
application's deployment descriptor. Instead, you just drop your servlet into WEB-
INF/classes and use the URL http://host/servlet/ServletName . The invoker servlet
isextremely convenient when you are learning and even when you are doing your
initialdevelopment.
To enable the invoker servlet, uncomment the following servlet and servlet-mapping
elements in install_dir/conf/web.xml. Finally, remember to make a backup copyof the
original version of this file before you make the changes.
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
PROGRAM 8
Objective: Assume four users user1, user2, user3 and user4 having the
passwords pwd1, pwd2, pwd3 and pwd4 respectively. Write a servlet for
doing the following.
1. Create a Cookie and add these four user id’s and passwords to this Cookie.
2. Read the user id and passwords entered in the Login form (week1) and
authenticate with the values (user id and passwords) available in the cookies.
PROGRAM:
cologin.html:
<html>
<head>
<title> login Page </title>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body>
<form ACTION="clogin">
<label> Login </label>
<input type="text" name="usr" size="20"> <br> <br>
<label> Password </label>
<input type="password" name="pwd" size="20"> <br> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
cologin1.html
<html>
<head>
<title> login Page </title>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body>
<form ACTION="clogin1">
<label> Login </label>
<input type="text" name="usr" size="20"> <br> <br>
<label> Password </label>
<input type="password" name="pwd" size="20"> <br> <br>
<input type="submit" value="submit">
</form>
</body>
</html>
Addcook.java:
import javax.servlet.* ;
import javax.servlet.http.*;
import java.io.*;
public class Addcook extends HttpServlet
{
String user,pas;
public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
Cookie c1=new Cookie("usr1","suni");
Cookie p1=new Cookie("pwd1","ani");
Cookie c2=new Cookie("usr2","abc");
Cookie p2=new Cookie("pwd2","123");
Cookie c3=new Cookie("usr3","def");
Cookie p3=new Cookie("pwd3","456");
Cookie c4=new Cookie("usr4","mno");
Cookie p4=new Cookie("pwd4","789");
res.addCookie(c1);
res.addCookie(p1);
res.addCookie(c2);
res.addCookie(p2);
res.addCookie(c3);
res.addCookie(p3);
res.addCookie(c4);
res.addCookie(p4);
out.println("COOKIE ADDED");
}
}
Clogin.java:
import javax.servlet.* ;
import javax.servlet.http.*;
import java.io.*;
public class Clogin extends HttpServlet
{
String user,pas;
public void service(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
user=req.getParameter("usr");
pas=req.getParameter("pwd");
Cookie[] c=req.getCookies();
for(int i=0;i<c.length;i++)
{
if((c[i].getName().equals("usr1")&&c[i+1].getName().equals("pwd1"))|| c[i].getName().equals("usr2")
&&c[i+1].getName().equals("pwd2"))||(c[i].getName().equals("usr3")&&
c[i+1].getName().equals("pwd3"))||(c[i].getName().equals("usr4")&& c[i+1].getName().equals("pwd4") ))
{
if((user.equals(c[i].getValue()) && pas.equals(c[i+1].getValue())) )
{
//RequestDispatcher rd=req.getRequestDispatcher("/cart.html");
rd.forward(req,res);
}
else
{
out.println("YOU ARE NOT AUTHORISED USER ");
//res.sendRedirect("/cookdemo/cologin.html");
}
}
}
}
}
Web.xml:
<web-app>
<servlet>
<servlet-name>him</servlet-name>
<servlet-class>Clogin</servlet-class>
</servlet>
<servlet>
<servlet-name>him1</servlet-name>
<servlet-class>Addcook</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>him</servlet-name>
<url-pattern>/clogin</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>him1</servlet-name>
<url-pattern>/clogin1</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
2. Read the user id and passwords entered in the Login form (week1) and authenticate with the values (user
id and passwords) available in the cookies.
If he is a valid user (i.e., user-name and password match) you should welcome him by name (user-name) else
you should display “You are not an authenticated user “.
Use init-parameters to do this. Store the user-names and passwords in the webinf.xml and access them in
the servlet by using the getInitParameters() method.
home.html:
<html>
<head>
<title>Authentication</title>
</head>
<body>
<form action="ex1">
<label>Username </label>
<input type="text"size="20" name="user"><br><br>
password<input type="text" size="20" name="pwd"><br><br>
<input type="submit" value="submit">
</form>
</body>
</html>
Example1.java
import javax.servlet.*;
import java.io.*;
public class Example1 extends GenericServlet
{
private String user1,pwd1,user2,pwd2,user3,pwd3,user4,pwd4,user5,pwd5;
public void init(ServletConfig sc)
{
user1=sc.getInitParameter("username1");
pwd1=sc.getInitParameter("password1");
user2=sc.getInitParameter("username2");
pwd2=sc.getInitParameter("password2");
user3=sc.getInitParameter("username3");
pwd3=sc.getInitParameter("password3");
user4=sc.getInitParameter("username4");
pwd4=sc.getInitParameter("password4");
}
Public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
user5=req.getParameter("user");
pwd5=req.getParameter("pwd");
if((user5.equals(user1)&&pwd5.equals(pwd1))||(user5.equals(user2)&&pwd5.equals(pwd2))||(user5.equals(user3)&&pwd5.equals(
pwd3))||(user5.equals(user4)&&pwd5.equals(pwd4)))
out.println("<p> welcome to"+user5.toUpperCase());
else
out.println("You are not authorized user");
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>Example</servlet-name>
<servlet-class>Example1</servlet-class>
<init-param>
<param-name>username1</param-name>
<param-value>pvpsit</param-value>
</init-param>
<init-param>
<param-name>password1</param-name>
<param-value>cse</param-value>
</init-param>
<init-param>
<param-name>username2</param-name>
<param-value>1234</param-value>
</init-param>
<init-param>
<param-name>password2</param-name>
<param-value>4567</param-value>
</init-param>
<init-param>
<param-name>username3</param-name>
<param-value>cse</param-value>
</init-param>
<init-param>
<param-name>password3</param-name>
<param-value>pvpsit</param-value>
</init-param>
<init-param>
<param-name>username4</param-name>
<param-value>wt</param-value>
</init-param>
<init-param>
<param-name>password4</param-name>
<param-value>lab</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Example</servlet-name>
<url-pattern>/ex1</url-pattern>
</servlet-mapping>
</web-app>
PROGRAM 9
Objective: Install a database (Mysql or Oracle). Create a table which should contain at
least the following fields: name, password, email-id, phone number Write a java
program/servlet/JSP to connect to that database and extract data from the tables and
display them. Insert the details of the users who register with the web site, whenever a new
user clicks the submit button in the registration page.
PROGRAM:
Registration.html:
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor="#00FFFf">
<form METHOD="POST" ACTION="register">
<CENTER>
<table>
<center>
<tr> <td> Username </td>
<td><input type="text" name="usr"> </td> </tr>
<tr><td> Password </td>
<td><input type="password" name="pwd"> </td> </tr>
<tr><td>Age</td>
<td><input type="text" name="age"> </td> </tr>
<tr> <td>Address</td>
<td> <input type="text" name="add"> </td> </tr>
<tr> <td>email</td>
<td> <input type="text" name="mail"> </td> </tr>
<tr> <td>Phone</td>
<td> <input type="text" name="phone"> </td> </tr>
<tr> <td colspan=2 align=center> <input type="submit" value="submit"> </td> </tr>
</center>
</table>
</form>
</body>
Login.html
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor=pink> <center> <table>
<form METHOD="POST" ACTION="authent">
<tr> <td> Username </td>
<td><input type="text" name="usr"></td> </tr>
<tr> <td> Password </td>
<td> <input type="password" name="pwd"> </td> </tr>
<tr> <td align=center colspan="2"><input type="submit" value="submit"></td> </tr>
</table> </center>
</form>
</body>
</html>
Ini.java:
import javax.servlet.*;
import java.sql.*;
import java.io.*;
public class Ini extends GenericServlet
{
private String user1,pwd1,email1;
web.xml:
<web-app>
<servlet>
<servlet-name>init1</servlet-name>
<servlet-class>Ini</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>init1</servlet-name>
<url-pattern>/regis</url-pattern>
</servlet-mapping>
</web-app>
OUTPUT:
PROGRAM 10:
Objective: Write a JSP which insert the details of the 3 or 4 users who register with the
the web site by using registration form. Authenticate the user when he submits the login
form using the username and password.
PROGRAM:
Login.html:
<!--Home.html-->
<html> <body>
<center><h1>XYZ Company Ltd.</h1></center>
<table border="1" width="100%" height="100%">
<tr>
<td valign="top" align="center"><br/>
<form action="auth.jsp"><table>
<tr>
<td colspan="2" align="center"><b>Login Page</b></td>
</tr>
<tr>
<td colspan="2" align="center"><b> </td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="user"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pwd"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="LogIN"/></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
Auth.jsp:
<%@page import="java.sql.*;"%>
<html>
<head>
<title>
This is simple data base example in JSP</title>
</title>
</head>
<body bgcolor="yellow">
<%!String uname,pwd;%>
<%
uname=request.getParameter("user");
pwd=request.getParameter("pwd");
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@195.100.101.158:1521:CCLAB","scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select name,password from personal where name='"+uname+"' and
password='"+pwd+"'"); if(rs.next())
{
out.println("Authorized person");
}
else
{
out.println("UnAuthorized person");
}
con.close();
}
catch(Exception e){out.println(""+e);}
%>
</body>
</html>
OUTPUT: