Professional Documents
Culture Documents
5. IMPLEMENTATION
5.1 IMPLEMENTATION:
HTTP URL
FTP URL
JSP’s are not run in the same sense as applets and applications.
Java Server pages provide functionality that extends a server. There are many web
servers that support java server pages. It is beyond the scope of this course to
cover the different ways to install jsp’s in each server.
5.3 CODING
LOGIC:
This screen gives references to all other screens present in the project.
The screen is developed using html language. This is the main screen
of the project.
CODE:
<html>
<head>
<title>Narayana chips (p)Ltd.</title>
</head>
<body bgcolor=white text=black link=black vlink="black" alink=red
onLoad="fun()">
<table border=0 width=100% align=center valign=middle>
<tbody>
<tr width=100%>
<td align=center width=13%>
<img src=ncp.gif width=50 height=70></img>
Website development for a Company 64
<div style="position:absolute;top:210;left:35">
<a href="http://192.168.100.47:8080/prj/careers.html"><b>
<font size=4>Careers</font></b></a></div>
<div style="position:absolute;top:280;left:38">
<a href="http://192.168.100.47:8080/prj/login.html"><b>
<font size=4>Login</font></b></a></div>
<div style="position:absolute;top:355;left:35">
<a href="http://192.168.100.47:8080/prj/search.html"><b>
<font size=4>Search</font></b></a></div></td>
<td width=80%>
<img src=globe.wmf width=615 height=220 style="z-index:-1">
<div style="position: absolute;top=250;left:590;z-index:1">
<a href=http://192.168.100.47:8080/prj/aboutus.html>
<img src=enter.gif width=50 height=50 border=0></img></a></div>
</tr>
</tbody>
</table>
</form>
</body>
</html>
Website development for a Company 66
HRD SCREEN:
LOGIC:
This is the screen that displays the employees that are working in the
company. It is a jsp file. The main statements that are used in this file are
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:company","user",
“pwd”);
PreparedStatement ps=con.prepareStatement ("select * from company");
ResultSet rs=ps.executeQuery ();
These statements are used for connecting to jdbc driver and to retrieve
the data from the database company.
CODE:
<html>
<head>
<title>Human Resource Department</title>
</head>
<body text=white bgcolor=Black link=yellow vlink=aqua alink=green>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%
PreparedStatement ps=null;
ResultSet rs=null;
Connection con=null;
String id1=null;
Website development for a Company 67
out.print("<font color=white>");
out.print(rs.getString(9));
out.print("</font></tr></tbody></table");
out.print("<br/><br/><center>
<img src='pencil.gif'></img></center><br/>");
}
}
%>
</form>
</body>
</html>
Website development for a Company 69
EXAM.JSP:
LOGIC:
This file is used to conduct the aptitude test. In this 15 questions are
displayed and these questions are retrieved randomly from the database by using
Random () function.
Random ran = new Random();
ran.nextInt(50);
The above function gives random numbers that are less than 50.
Code:
<html>
<head>
<title> Aptitude Test</title>
<Script language="JavaScript">
var i=899;
function timer()
{
SetInterval ("timers ()", 1000);
}
Website development for a Company 70
function timers()
{
Window.Status=i;
i--;
}
function state()
{
window.status=900;
}
function start()
{
setInterval("end()", 906000);
}
function end()
{
alert("Oh! No ! Time over.");
document.Write("<tablewidth=80% align=center height=400>
<tbody>
<tr bgcolor=navy><td align=center>
<Font size=4color=yellow>
You are not qualified in the
Aptitude Test
<br/>. <br/>
<a href='http://192.168.100.47:8080/prj/homepage.html'>
<img src='home.bmp' border=0></img></a></tr></tbody></table>");
}
Window.onLoad=start();
Window.onLoad=timer();
Window.onLoad=state();
</script>
Website development for a Company 71
<body>
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con1=DriverManager.getConnection ("jdbc:odbc:application",
"batch11", "bandi");
PreparedStatement ps2=con1.prepareStatement ("select * from
application”);
ResultSet rs2=ps2.executeQuery ();
while(rs2.next())
if((rs2.getString(3)).equals(id))
exam=rs2.getString (16);
if(exam.equals("NONE"))
{
String qry="update application set exam='YES' where
id='"+id+"'";
PreparedStatement ps1=con1.prepareStatement(qry);
ps1.executeUpdate();
for(int j=0;j<15;j++)
arr[j]=ran.nextInt(59)+1;
for(int j=0;j<15;j++)
for(int k=0;k<15;k++)
if(arr[j]<arr[k])
{
temp=arr[j];
arr[j]=arr[k];
arr[k]=temp;
}
Website development for a Company 72
for(int k=0;k<15;k++)
for(int j=0;j<15;j++)
if((arr[k]==arr[j]) && (k!=j))
arr[j]=arr[k]+1;
Connection con=DriverManager.getConnection ("jdbc:odbc: exam", "batch11",
"bandi");
PreparedStatement ps=con.prepareStatement ("select * from exam order by qno");
ResultSet rs=ps.executeQuery ();
%>
<td width=25% valign=top>
<%
out.print("<input type=radio name="+(char)(c+i)+"
value=4>"+rs.getString(4)+" ");
%>
<td width=25% valign=top>
<%
out.print("<input type=radio name="+(char)(c+i)+"
value=5>"+rs.getString(5)+" ");
%>
<td width=25% valign=top>
<%
out.print("<input type=radio name="+(char)(c+i)+"
value=6>"+rs.getString(6)+<br><br><br>");
%>
</tr></tbody></table><br/>
<%
i++;
%>
<center><input type=submit value=Finish></center></form>
<%
}
Website development for a Company 74
else
{
RESULT.JSP:
LOGIC:
This is used to find the result of the exam. First we retrieved the
question numbers that are displayed in the test from the exam file and then getting
the answers applied by the user. By comparing these answers with original
answers, we calculate the score.
CODE:
<html>
<body>
<% page language=java>
<%
while(i<15)
{
Connection con=DriverManager.getConnection ("jdbc:odbc:exam",
"batch11", "bandi");
PreparedStatement ps=con.prepareStatement ("select * from exam");
ResultSet rs=ps.executeQuery ();
while(rs.next())
{
if(rs.getInt(1)==bb[i])
{
ans[i++]=rs.getString(7);
break;
}
}
}
Website development for a Company 76
for(int j=0;j<15;j++)
if(an[j]==null)
bb1[j]=8;
else
bb1[j]=Integer.parseInt(an[j]);
for(int k=0;k<15;k++)
if(ans[k].equals(an[k]))
count++;
%>
</body>
</html>
Website development for a Company 77
Mailing Screen:
Logic:
Employees use this page to see the offline messages send.
The main logic is retrieving the fields from the database mail and displaying it.
CODE:
<html>
<body>
<%
out.print("<div align=right>[
<a href='http://192.168.100.47:8080/prj/logout.jsp?id="+id+"'>Logout</a>
]</div>");
%>
<br/><table width=100% align=center border=0 height=30
bgcolor=lightgreen><tbody><tr><td width=400>
<font color=red size=4>Welcome, </font><font color=purple
size=4><u>
<%
while(rs.next()) if(rs.getString(1).equals(id))
{
%>
<tr height=40><td width=30% align=center>
<%
out.print(rs.getString(2));
%>
<td width=30% align=center>
<%
String subject=rs.getString(3);
Website development for a Company 78
String datetime=rs.getString(4);
out.print("<a href='http://192.168.100.47:8080/prj/message.jsp?id="+id+"
&subject="+subject+"&datetime="+datetime+"'>"+subject+"</a>");
%>
<td width=40% align=center>
<%
out.print(datetime+"</tr>");
}
%>
</tbody></table>
</body>
</html>
Website development for a Company 79
COMPOSE Screen:
LOGIC:
This page is used to send mails to other employees. Sending the
mail to other employee storing the data in the database of corresponding user for
whom the mail is send.
CODE:
<html>
<head>
<title>Sending the mail</title>
</head>
<body bgcolor=black text=white background="o002.jpg" vlink=red alink=aqua
link=lightblue>
<%
out.print("<div align=right>[
<a
href='http://192.168.100.47:8080/prj/logout.jsp?id="+mailfrom+"'>Logout</a>
]</div>");
try
{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con1=DriverManager.getConnection ("jdbc:odbc:
“company","batch11", "bandi");
While (rs1.next ())
if((rs1.getString(1)).equals(mailto))
m++;
Prepared Statement ps2=con1.prepareStatement ("select * from
Website development for a Company 80
company");
if(flag==1)
{
If(m==1)
{
Connection con=DriverManager.getConnection ("jdbc:odbc: mail",
"batch11", "bandi");
Prepared Statement ps=con.prepareStatement ("insert into mail
(mailto, mailfrom, subject, datetime, data) values (?,?,?,?,?)");
Ps.clearParameters ();
Ps.setString (1, mailto);
Ps.setString (2, mailfrom);
Ps.setString (3, subject);
Ps.setString (4, datetime);
Ps.setString (5, data);
Ps.executeUpdate ();
%>
<br/><br/><br/>
<Table width=70% height=250 align=center>
<Tbody>
<tr width=80%><td align=center><font color=blue size=6>
Message send.
</font><tr/>
<tr width=20%>
<td align=center>
Website development for a Company 81
<%
out.print("<form action='http://192.168.100.47:8080/prj/logincheck.jsp'
method=post>");
out.print("<input type=hidden name=id value="+mailfrom+">");
out.print("<input type=hidden name=password value="+password+">");
%>
<input type=submit value=Return to Mail>
</form>
</tbody>
</table>
<%
}
else if(m==0)
{
out.print("<form action='http://192.168.100.47:8080/prj/compose.jsp'>
<table align=center border=0 bgcolor=lightblue width=500 height=300>
<tbody><tr align=center valign=middle><td align=center>
<font size=4 color=white>No such employee exist in the company.
<br/><br/>
<input type=hidden name=id value="+mailfrom+">
<input type=submit value=Back></font></tr></tbody></table></form>");
}
}
%>
</body>
</html>
Website development for a Company 82
LEAVE.JSP:
LOGIC:
This page allows the employees to take leave by online. Each
employee has a leave of 5 days in a month. If employees has sufficient leaves then
only the leave is granted otherwise it is rejected.
CODE:
<html>
<head>
<title>Online Leave Taking</title>
</head>
<body onLoad="startclock(); timerONE=window.setTimeout" bgcolor=white
text=black background=a051.jpg>
<%
out.print("<div align=right>[
<a
href='http://localhost:8080/prj/logout.jsp?id="+id+"'>Logout</a> ]</div>");
out.print("<br/><table width=100% align=center border=0 height=30
bgcolor=lightgreen><tbody><tr><td width=400>");
out.print("<font color=red size=4>Welcome,
</font><u><font color=purple size=4>");
out.print(id+"@ncp.com");
out.print("</font></u><td align=right><input type=button name=time1
style='background:white'></tr></tbody></table>");
out.print("<hr width=100% align=center noshade color=blue/>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Website development for a Company 83
Connection con=DriverManager.getConnection("jdbc:odbc:company",
"batch11", "bandi");
PreparedStatement ps=con.prepareStatement("select * from company");
ResultSet rs=ps.executeQuery();
while(rs.next()) if(rs.getString(1).equals(id)) leavesrem=rs.getInt(17);
%>
<table width=500 align=center valign=middle height=220 border=0><tbody>
<tr><td width=40% align=right><b>Employee ID : </b>
<%
out.print("<td><b>"+id+"</b><input type=hidden name=id value="+id+">");
out.print("</tr><tr><td align=center colspan=2><b>Your leaves remaining are
"+leavesrem+" </b></tr>");
%>
<tr>
<td width=50% align=right><b>Select how many days you want : </b>
<td>
</tr>
<tr>
<td width=40% align=right>
<b>FROM : </b>
<td><input type=text name="dayfrom">
</tr>
<tr>
<td width=40% align=right>
<b>TO : </b>
<td><input type=text name="dayto">
</tr>
<tr>
Website development for a Company 84
<br/><br/>
<center>
<input type=submit value="Apply Leave">
</center>
</form>
</body>
</html>
Website development for a Company 85
SEARCH.JSP:
LOGIC:
CODE:
<html>
<head>
<title>Details of Employee</title>
</head>
<body text=lightblue bgcolor=black>
<%
while(rs.next()) if(rs.getString(2).equals(fname)) m=m+1;
if(m==0)
out.print("No one found");
if(m==1)
{
PreparedStatement ps1=con.prepareStatement("select * from company");
ResultSet rs1=ps1.executeQuery();
while(rs1.next())
{
String name=rs1.getString(2);
if(name.equals(fname))
{
%>
<center>
<h2><u>Employee Details</u></h2>
</center>
<table width=500 height=360 align=center border=0 background=bg37.jpg><tbody>
Website development for a Company 86
<tr>
<td width=50% align=right height=20><font color=red
size=3>ID : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(1));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>First Name : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(name);%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Last Name : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(3));%>
</b></font>
</tr>
<tr>
Website development for a Company 87
<%out.print(rs1.getString(4));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Date of Birth : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(6));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Gender : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(7));%>
</b></font>
</tr>
<tr>
<%out.print(rs1.getString(8));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Address : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(9));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Phone Number : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(10));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Martial Status : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(11));%>
</b></font>
Website development for a Company 89
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Position : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(13));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Salary : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(14));%>
</b></font>
</tr>
<tr>
<td width=50% align=right height=20><font color=red
size=3>Admit Date : </font>
<td width=50% align=left height=20><font color=white size=3><b>
<%out.print(rs1.getString(16));%>
</b></font>
</tr></tbody></table>
<%
}}}
Website development for a Company 90
If more than employees has same name then their corresponding id’s are displayed.
On clicking the corresponding id their internal details are displayed.
if(m>1)
{
PreparedStatement ps2=con.prepareStatement ("select * from
company");
ResultSet rs2=ps2.executeQuery ();
While (rs2.next ())
{
if(rs2.getString(2).equals(fname))
{
out.print("<br/><table width=90% height=120 bgcolor=gray
align=center><tbody>");
out.print("<tr><td width=10% height=33% align=right>");
out.println(fathername+"<td wdith=23% height=33%
align=left>
<a href='http://192.168.100.47:8080/prj/details.jsp?
Id="+rs2.getString(1)+"'>"+rs2.getString(4)+"</a>");
out.print("</font></tr>");
out.print("<tr><td width=10% height=33% align=right>");
out.print(dob);
out.print("<td width=23% height=33% align=left>");
out.print("<font color=white>");
out.print(rs2.getString(6));
out.print("</font></tr>");
out.print("<tr><td width=10% height=33% align=right>");
out.print(gender);
out.print("<td width=23% height=33% align=left>");
out.print("<font color=white>");
out.print(rs2.getString(7));
Website development for a Company 91
out.print("</font></tr>");
out.print("<tr><td width=10% height=34% align=right>");
out.print(address);
out.print("<td width=23% height=33% align=left>");
out.print("<font color=white>");
out.print(rs2.getString(9));
out.print("</font></tr></tbody></table");
out.print("<br/><br/><img src='pencil.gif'
align=center/><br/>");
}}}
%><br/>
<center>
<a href="http://192.168.100.47:8080/prj/homepage.html"><img src=home.bmp
border=0></img></a>
<a href="http://192.168.100.47:8080/prj/aboutus.html"><img src=aboutus.bmp
border=0></img></a>
</center>
<hr width=100% color="red">
<font face="Times New Roman" color="yellow">
</font>
</body>
</html>