Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4...
-
date post
22-Dec-2015 -
Category
Documents
-
view
229 -
download
0
Transcript of Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4...
![Page 1: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/1.jpg)
ExampleExample
Student Record ApplicationStudent Record Application
![Page 2: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/2.jpg)
EnvironmentEnvironment Run environment: JDK 1.4Run environment: JDK 1.4
Web server: TOMCAT as JSP containerWeb server: TOMCAT as JSP container
Application Server: pure Java ClassApplication Server: pure Java Class
Database: Oracle + JDBC driverDatabase: Oracle + JDBC driver
Development toolDevelopment tool NetBeans IDE 3.5.1NetBeans IDE 3.5.1
ANT+NotepadANT+Notepad
![Page 3: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/3.jpg)
TomcatTomcat
Tomcat is a Servlet/JSP containerTomcat is a Servlet/JSP container
Tomcat implements the Servlet and Tomcat implements the Servlet and JavaServer Pages specifications from JavaServer Pages specifications from Java Software Java Software
![Page 4: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/4.jpg)
J D K
T O M C A TJ av aC las s
O R A C L EB ro swe r
Architecture of Student Record Architecture of Student Record applicationapplication
![Page 5: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/5.jpg)
Development work flowDevelopment work flowL o g ic A n a lys is
L o g ic D e s ig n
C o d e
P re p a re D a ta b a s e
C o nfig ueA pplic a tio n
D e plo yA pplic a tio n
R u n A p p lic a tio n
![Page 6: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/6.jpg)
Logic analysisLogic analysis
Under the support of Rational XDE
Student
+ id+ firstname+ surname
+ add ( )+ modify ( )+ delete ( )+ get ( )
![Page 7: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/7.jpg)
Logic designLogic design
Server Side: Servlet + pure java class Server Side: Servlet + pure java class
Client Side: JSP Client Side: JSP
![Page 8: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/8.jpg)
Logical Architecture of Server Logical Architecture of Server Side Side
Under the support of Rational XDE
Design on J2EE framework
«JavaInterface»ServletContextListener
+ contextInitialized ( )+ contextDestroyed ( )
«JavaInterface»ContextListener
Student
+ id+ firstname+ surname
+ getID ( )+ getFirstname ( )+ getSurname ( )+ getFullname ( )+ getFullstudents ( )
StudentsDB
+ connection+ connectionFree+ Students
+ addStudent ( )+ deleteStudent ( )+ modifyStudent ( )+ getStudent ( )+ getStudents ( )+ getConnection ( )+ releaseConnection ( )+ close ( )
- theStudentsDB
0..1
- theStudent
0..1
![Page 9: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/9.jpg)
ContextListenerContextListener
<?xml version="1.0" encoding="UTF-8"?><?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN“PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN“ "http://java.sun.com/dtd/web-app_2_3.dtd">"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app><web-app>
<description>Oracle Test App</description><description>Oracle Test App</description> <listener><listener> <listener-class>StudentPackage.contextlisenter</listener-class><listener-class>StudentPackage.contextlisenter</listener-class> </listener></listener>
</web-app></web-app>
Web.xmlWeb.xml
![Page 10: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/10.jpg)
JSP Logical Architecture of Client JSP Logical Architecture of Client Side Side
Hom e.js p
R e q u e s tD e le te.js p
D o D e le te.js p
R e q u e s tA d d.js p
R e q u e s tM o d ify.js p
D o A d d.js p
D o M o d ify.js p
![Page 11: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/11.jpg)
JSPJSP
H o m e .js p
R e qu e s tD e le te.js p
D oD e le te.js p
R e qu e s tA dd.js p
R e qu e s tM odi fy.js p
D oA dd.js p
D oM odi fy.js p
de l e teadd m o di fy
c o nt i nue c o nt i nue
c o nt i nuec o nt i nuec o nt i nue
c o nt i nue
abo r tabo r t abo r t
E n try P o in t
![Page 12: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/12.jpg)
Student Record Application Run Student Record Application Run CycleCycle
Install or Start StudentRecord Application
Call up JSP
Stop StudentRecord application
![Page 13: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/13.jpg)
S tud entR ec o rdis initialized
C o n te x tL is te n e r.c o ntextInitialized ( )
C r e ate an i ns tanc e o fStude nts D B
S tu d e n ts D B .c o ns truc to r( )
c o nne c t i o n us i ng the jdbc /o r ac l e D ataSo ur c eto Ac c e s s D atabas e vi a
J D B C D r i ve r , U R L , us e r nam e and pas s o w r d
o ra c le .jd b c .d riv e r.O ra c le D riv e r
O ra c le D a ta b a s e
Sto r eStude nts D B i ns tanc ei n Se r vl e t Attr i bute
"Stude nts D B "" S tu d e n ts D B "
S e rv le t A ttrib u te(S tud ent)
Install or Start StudentRecord Application
![Page 14: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/14.jpg)
Contextlistener start an Contextlistener start an ApplicationApplication
public void contextInitialized(ServletContextEvent sce) {public void contextInitialized(ServletContextEvent sce) { ServletContext sc= sce.getServletContext();ServletContext sc= sce.getServletContext(); trytry {{ StudentPackage.StudentDB studentdb= new StudentPackage.StudentDB studentdb= new
StudentPackage.StudentDB();StudentPackage.StudentDB(); sc.setAttribute ("studentdb", studentdb);sc.setAttribute ("studentdb", studentdb); }} catch (Exception e)catch (Exception e) {{ sc.log ("Couldn't create database attribute: " + sc.log ("Couldn't create database attribute: " +
e.getMessage ());e.getMessage ()); } } }// end of public void contextInitialized(ServletContextEvent e)}// end of public void contextInitialized(ServletContextEvent e)
![Page 15: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/15.jpg)
c al l upHom e.js p
J SP i s c o m pl i e dand e xe c ute d c o m pl ie d
H o m e .jspR e tr i ve
Stude nts D B fr o mSe r vl e t Attr i bute
"Stude nts D B "
" S tu d e n ts D B "S e rv le t A ttrib u te
(S tu d e n t)
Aqui r e a i ns tanc e o fStude nts D B
S tu d en ts D B
R e ad s tude nt r e c o r d
o ra c le .jd b c .d riv e r.O ra c le D riv e r
O racle
R e tur n s tude nt r e c o r d
R e tur n s tude nt r e c o r d
D i s pl ay s tude nt r e c o r d
Call up Home.jsp
![Page 16: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/16.jpg)
Use StudentDB instanceUse StudentDB instance
<%<% StudentPackage.StudentDB studentdb= StudentPackage.StudentDB studentdb=
(StudentPackage.StudentDB) (StudentPackage.StudentDB) application.getAttribute("studentdb");application.getAttribute("studentdb");
Collection students = studentdb.getStudents();Collection students = studentdb.getStudents();
%>%>
Home.jspHome.jsp
![Page 17: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/17.jpg)
S to pS tu d e n tR e c o rd
C o nte xtL is te ne r.c o nte xtD e s tro ye d( )
" S tu d en tsD B "S erv le t A ttrib u te
(S tu d en t)
R e m o v eS tu d e n ts D B
in S e rv le t A ttrib u te" S tu d e n ts D B "
R e triv eS tu d e n ts D B fro mS e rv le t A ttrib u te
" S tu d e n ts D B " C o m pl i e dJ AVA Se r ve r
P ag e s
A c q u ire a in s tan c e o fS tu d e n ts D B
S tude nts D B
C lo s e D atab as e
O ra c le
o ra c le .jdbc .drive r.O ra c le D rive r
D e s to ry in s tan c e o fS tu d e n ts D B
Stop Student Record Application
![Page 18: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/18.jpg)
Contextlistener stop an Contextlistener stop an ApplicationApplication
public void contextDestroyed(ServletContextEvent public void contextDestroyed(ServletContextEvent sce) {sce) {
ServletContext sc = sce.getServletContext ();ServletContext sc = sce.getServletContext (); StudentPackage.StudentDB studentdb = StudentPackage.StudentDB studentdb =
(StudentPackage.StudentDB) (StudentPackage.StudentDB) sc.getAttribute("studentdb");sc.getAttribute("studentdb");
studentdb.close();studentdb.close(); sc.removeAttribute ("studentdb");sc.removeAttribute ("studentdb"); }}
![Page 19: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/19.jpg)
Prepare DatabasePrepare Database
Create tableCreate tableCREATE TABLE STUDENTDBCREATE TABLE STUDENTDB
( ID NUMBER(10) NOT NULL PRIMARY KEY, ( ID NUMBER(10) NOT NULL PRIMARY KEY,
FIRSTNAME VARCHAR2(30) NOT NULL,FIRSTNAME VARCHAR2(30) NOT NULL,
SURNAME VARCHAR2(30) NOT NULLSURNAME VARCHAR2(30) NOT NULL
););
Insert student recordInsert student recordinsert into studentdb (id, firstname, surname) insert into studentdb (id, firstname, surname)
values (101,'Emma','Dean');values (101,'Emma','Dean');
![Page 20: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/20.jpg)
Configure ApplicationConfigure Application
StudentRecord's Development Directory under NetBeans
![Page 21: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/21.jpg)
Configure Application Configure Application (Cont.)(Cont.)
build.propertiesbuild.properties
![Page 22: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/22.jpg)
Configure Application Configure Application (Cont.)(Cont.)
Build.xmlBuild.xml Server.xmlServer.xml Web.xmlWeb.xml
![Page 23: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/23.jpg)
Configure Application Configure Application (Cont.)(Cont.)
/src/*.java/src/*.java
![Page 24: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/24.jpg)
Configure Application Configure Application (Cont.)(Cont.)
/web/*.jsp/web/*.jsp
![Page 25: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/25.jpg)
Building, Installing, Building, Installing, Deploying Deploying
Use ANT to build, install and deploy Use ANT to build, install and deploy Student Record ApplicationStudent Record Application
Use Neatbeans IDE to build Student Use Neatbeans IDE to build Student Record ApplicationRecord Application
![Page 26: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/26.jpg)
Run ApplicationRun Application
![Page 27: Example Student Record Application. Environment Run environment: JDK 1.4 Run environment: JDK 1.4 Web server: TOMCAT as JSP container Web server: TOMCAT.](https://reader030.fdocuments.net/reader030/viewer/2022032704/56649d7a5503460f94a5e21d/html5/thumbnails/27.jpg)
EndEnd
Thank you.Thank you.