This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
5. IMPLEMENTATION 5.1 IMPLEMENTATION: Java Server Pages is a simple, yet powerful technology for creating and maintaining dynamic-content web pages. Based on the Java programming language, Java Server Pages offers proven portability, open standards, and a mature re-usable component model. JSP’s are designed to work within a request / response – processing model. In a request / response model, a client sends a request message to a server and the server responds by sending back a reply message. Requests can come in the form of a custom protocol. HTTP URL FTP URL
MIDDLE TIER PROCESS: In many systems, a middle tier serves as a link between clients and back-end services. By using a middle tier a lot of processing can be off-loaded form both clients (making them lighter and faster) and servers (allowing them to focus on their mission). One advantage of middle tier processing is simply connection management. A set of jsp’s could handle connections with hundreds of clients, if clients, if not thousands, while recycling a pool of expensive connections to database servers.
Website development for a Company
62
Other middle tier roles include: Business rule enforcement Transaction Management Mapping clients to redundant set of servers Supporting different types of clients such as pure HTML and java capable clients.
INSTALLING JAVA SERVER PAGES: 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.
USING JAVA WEB SERVER: Sun Java Web Server (JWS) is a full-featured product. Nice feature is it’s ability to detect when a java server pages has been updated. It detects when new class files have been copied to the appropriate public_html directory and it necessary, automatically reloads any running Jsp pages.
Java Server Pages are installed by moving them to the C:\Java Web Server2.0\public_html directory
Website development for a Company
63
5.3 CODING The coding step of software development is a process of transition of the detailed design into a programming language that is ultimately transformed into machine executable instructions. This coding depends on the proper selection of the language and coding style of the preliminary design level specified in the design phase.
CODING FOR SCREENS: HOMEPAGE: 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: Narayana chips (p)Ltd.
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.
Website development for a Company out.print(""); out.print(rs.getString(9)); out.print("
"); } } %>
68
Website development for a Company
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. Timer is also maintained for the exam by using Script language. Three methods are used here. They are 1.
start()
----- to start up the timer when examination is started.
2.
timer()
----- to set the interval for the timer.
3.
state()
----- to display the time on window status.
Code: Aptitude Test <Script language="JavaScript"> var i=899; function timer() { SetInterval ("timers ()", 1000); }
69
Website development for a Company
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("
Website development for a Company else { out.print("<script language='javascript'>alert('Oh ! No, You can't Refresh or Reload this page');"); %>
<% } } %>
74
Website development for a Company
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.
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.
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.
Website development for a Company company"); ResultSet rs2=ps2.executeQuery (); While (rs2.next ()) if ((rs2.getString (1)). equals (mailfrom)) Password=rs2.getString (5); 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 (); %>
Message send.
80
Website development for a Company
<% out.print("
<% } else if(m==0) { out.print(""); } } %>
81
Website development for a Company
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.
SEARCH.JSP: LOGIC: This page is used to display the internal details of the employee. The main logic is first search the given name with the names in the database. If the match found then all the fields of that tuple is displayed.
CODE: Details of Employee <% 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)) { %>
Employee Details
Website development for a Company
ID :
<%out.print(rs1.getString(1));%>
First Name :
<%out.print(name);%>
Last Name :
<%out.print(rs1.getString(3));%>
86
Website development for a Company
Father Name :
<%out.print(rs1.getString(4));%>
Date of Birth :
<%out.print(rs1.getString(6));%>
Gender :
<%out.print(rs1.getString(7));%>
Qualification :
87
Website development for a Company
<%out.print(rs1.getString(8));%>
Address :
<%out.print(rs1.getString(9));%>
Phone Number :
<%out.print(rs1.getString(10));%>
Martial Status :
<%out.print(rs1.getString(11));%>
88
Website development for a Company
Position :
<%out.print(rs1.getString(13));%>
Salary :
<%out.print(rs1.getString(14));%>
Admit Date :
<%out.print(rs1.getString(16));%>
<% }}}
89
Website development for a Company 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("