online multimedia communication system
TRANSCRIPT
California State University San Bernardino California State University San Bernardino
CSUSB ScholarWorks CSUSB ScholarWorks
Theses Digitization Project John M Pfau Library
2005
Online multimedia communication system Online multimedia communication system
Yin-Wei Yang
Follow this and additional works at httpsscholarworkslibcsusbeduetd-project
Part of the Digital Communications and Networking Commons
Recommended Citation Recommended Citation Yang Yin-Wei Online multimedia communication system (2005) Theses Digitization Project 2661 httpsscholarworkslibcsusbeduetd-project2661
This Thesis is brought to you for free and open access by the John M Pfau Library at CSUSB ScholarWorks It has been accepted for inclusion in Theses Digitization Project by an authorized administrator of CSUSB ScholarWorks For more information please contact scholarworkscsusbedu
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
A Project
Presented to the
Faculty of
California State University
San Bernardino
In Partial Fulfillment
of the Requirements for the Degree
Master of Science
in
Computer Science
by
Yin-Wei Yang
June 2005
ABSTRACT
Online Multimedia Communication System is a projectaimed at providing people the ability to store and share
their multimedia files The users and administrator can
modify and view the files and database information from a
normal web browser Furthermore this site offers a secure
environment to keep all the users private information
The project interface is a normal web browser and is
written in JSP (Java Server Page) and HTML (Hyper Text
Markup Language) The users can record modify and store
their multimedia files anytime or anywhere by using it
Online Multimedia Communication System is an easy touse application Everyone who can use a web browser can
easily login to upload his or her event files to sharewith other users
iii
ACKNOWLEDGMENTS
I would not have finished my graduate project
successfully without the support and encouragement of my
advisor my family and my friends I am so grateful to Dr
Botting who is such a wonderful advisor and he not only
offers me this chance to work with him but also directs methrough this entire effort I am also grateful to Dr
Turner and Dr Voigt to be my committee and provide
helpful comments on the project I am also appreciating
Dr Concepcion Dr Mendoza and Mr Dung Vu who let me
working in Active Capital Project as a student assistantBy doing the Active Capital Project I learned a lot ofthings and it is helpful from this project
Also I appreciate my family for all their love
understanding and tolerance They provide full financial
aid without them this project cannot be finished on timeI would like to share the honor with them
Finally I thank the faculty of Computer Science department for giving me an opportunity to pursue my MS
in Computer Science at California State University I also
want to thank all my friends who helped me during my
studying at CSUSB
iv
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGMENTS iv
LIST OF TABLESviii
LIST OF FIGURES ix
CHAPTER ONE INTRODUCTION
11 Purpose of This Project 1
12 Scope of Project 1
121 Deliverables 1
122 Function of Software Products 2
13 Significance of the Project 2
14 Definition and Abbreviations 3
15 Organization of the Documentation 4
CHAPTER TWO ONLINE MULTIMEDIA COMMUNICATIONSYSTEM ARCHITECTURE 5
21 Software Interfaces 7
CHAPTER THREE SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction 9
32 Overall Description 9
321 Product Perspective 9
322 Product Functions 10
323 Product Architecture 11
CHAPTER FOUR DATABASE DESIGN
41 Data Analysis 13
42 Database Schema Logical Model -Relational Schema 15
43 Data Type and Details 16
v
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
A Project
Presented to the
Faculty of
California State University
San Bernardino
In Partial Fulfillment
of the Requirements for the Degree
Master of Science
in
Computer Science
by
Yin-Wei Yang
June 2005
ABSTRACT
Online Multimedia Communication System is a projectaimed at providing people the ability to store and share
their multimedia files The users and administrator can
modify and view the files and database information from a
normal web browser Furthermore this site offers a secure
environment to keep all the users private information
The project interface is a normal web browser and is
written in JSP (Java Server Page) and HTML (Hyper Text
Markup Language) The users can record modify and store
their multimedia files anytime or anywhere by using it
Online Multimedia Communication System is an easy touse application Everyone who can use a web browser can
easily login to upload his or her event files to sharewith other users
iii
ACKNOWLEDGMENTS
I would not have finished my graduate project
successfully without the support and encouragement of my
advisor my family and my friends I am so grateful to Dr
Botting who is such a wonderful advisor and he not only
offers me this chance to work with him but also directs methrough this entire effort I am also grateful to Dr
Turner and Dr Voigt to be my committee and provide
helpful comments on the project I am also appreciating
Dr Concepcion Dr Mendoza and Mr Dung Vu who let me
working in Active Capital Project as a student assistantBy doing the Active Capital Project I learned a lot ofthings and it is helpful from this project
Also I appreciate my family for all their love
understanding and tolerance They provide full financial
aid without them this project cannot be finished on timeI would like to share the honor with them
Finally I thank the faculty of Computer Science department for giving me an opportunity to pursue my MS
in Computer Science at California State University I also
want to thank all my friends who helped me during my
studying at CSUSB
iv
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGMENTS iv
LIST OF TABLESviii
LIST OF FIGURES ix
CHAPTER ONE INTRODUCTION
11 Purpose of This Project 1
12 Scope of Project 1
121 Deliverables 1
122 Function of Software Products 2
13 Significance of the Project 2
14 Definition and Abbreviations 3
15 Organization of the Documentation 4
CHAPTER TWO ONLINE MULTIMEDIA COMMUNICATIONSYSTEM ARCHITECTURE 5
21 Software Interfaces 7
CHAPTER THREE SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction 9
32 Overall Description 9
321 Product Perspective 9
322 Product Functions 10
323 Product Architecture 11
CHAPTER FOUR DATABASE DESIGN
41 Data Analysis 13
42 Database Schema Logical Model -Relational Schema 15
43 Data Type and Details 16
v
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
ABSTRACT
Online Multimedia Communication System is a projectaimed at providing people the ability to store and share
their multimedia files The users and administrator can
modify and view the files and database information from a
normal web browser Furthermore this site offers a secure
environment to keep all the users private information
The project interface is a normal web browser and is
written in JSP (Java Server Page) and HTML (Hyper Text
Markup Language) The users can record modify and store
their multimedia files anytime or anywhere by using it
Online Multimedia Communication System is an easy touse application Everyone who can use a web browser can
easily login to upload his or her event files to sharewith other users
iii
ACKNOWLEDGMENTS
I would not have finished my graduate project
successfully without the support and encouragement of my
advisor my family and my friends I am so grateful to Dr
Botting who is such a wonderful advisor and he not only
offers me this chance to work with him but also directs methrough this entire effort I am also grateful to Dr
Turner and Dr Voigt to be my committee and provide
helpful comments on the project I am also appreciating
Dr Concepcion Dr Mendoza and Mr Dung Vu who let me
working in Active Capital Project as a student assistantBy doing the Active Capital Project I learned a lot ofthings and it is helpful from this project
Also I appreciate my family for all their love
understanding and tolerance They provide full financial
aid without them this project cannot be finished on timeI would like to share the honor with them
Finally I thank the faculty of Computer Science department for giving me an opportunity to pursue my MS
in Computer Science at California State University I also
want to thank all my friends who helped me during my
studying at CSUSB
iv
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGMENTS iv
LIST OF TABLESviii
LIST OF FIGURES ix
CHAPTER ONE INTRODUCTION
11 Purpose of This Project 1
12 Scope of Project 1
121 Deliverables 1
122 Function of Software Products 2
13 Significance of the Project 2
14 Definition and Abbreviations 3
15 Organization of the Documentation 4
CHAPTER TWO ONLINE MULTIMEDIA COMMUNICATIONSYSTEM ARCHITECTURE 5
21 Software Interfaces 7
CHAPTER THREE SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction 9
32 Overall Description 9
321 Product Perspective 9
322 Product Functions 10
323 Product Architecture 11
CHAPTER FOUR DATABASE DESIGN
41 Data Analysis 13
42 Database Schema Logical Model -Relational Schema 15
43 Data Type and Details 16
v
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
ACKNOWLEDGMENTS
I would not have finished my graduate project
successfully without the support and encouragement of my
advisor my family and my friends I am so grateful to Dr
Botting who is such a wonderful advisor and he not only
offers me this chance to work with him but also directs methrough this entire effort I am also grateful to Dr
Turner and Dr Voigt to be my committee and provide
helpful comments on the project I am also appreciating
Dr Concepcion Dr Mendoza and Mr Dung Vu who let me
working in Active Capital Project as a student assistantBy doing the Active Capital Project I learned a lot ofthings and it is helpful from this project
Also I appreciate my family for all their love
understanding and tolerance They provide full financial
aid without them this project cannot be finished on timeI would like to share the honor with them
Finally I thank the faculty of Computer Science department for giving me an opportunity to pursue my MS
in Computer Science at California State University I also
want to thank all my friends who helped me during my
studying at CSUSB
iv
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGMENTS iv
LIST OF TABLESviii
LIST OF FIGURES ix
CHAPTER ONE INTRODUCTION
11 Purpose of This Project 1
12 Scope of Project 1
121 Deliverables 1
122 Function of Software Products 2
13 Significance of the Project 2
14 Definition and Abbreviations 3
15 Organization of the Documentation 4
CHAPTER TWO ONLINE MULTIMEDIA COMMUNICATIONSYSTEM ARCHITECTURE 5
21 Software Interfaces 7
CHAPTER THREE SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction 9
32 Overall Description 9
321 Product Perspective 9
322 Product Functions 10
323 Product Architecture 11
CHAPTER FOUR DATABASE DESIGN
41 Data Analysis 13
42 Database Schema Logical Model -Relational Schema 15
43 Data Type and Details 16
v
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGMENTS iv
LIST OF TABLESviii
LIST OF FIGURES ix
CHAPTER ONE INTRODUCTION
11 Purpose of This Project 1
12 Scope of Project 1
121 Deliverables 1
122 Function of Software Products 2
13 Significance of the Project 2
14 Definition and Abbreviations 3
15 Organization of the Documentation 4
CHAPTER TWO ONLINE MULTIMEDIA COMMUNICATIONSYSTEM ARCHITECTURE 5
21 Software Interfaces 7
CHAPTER THREE SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction 9
32 Overall Description 9
321 Product Perspective 9
322 Product Functions 10
323 Product Architecture 11
CHAPTER FOUR DATABASE DESIGN
41 Data Analysis 13
42 Database Schema Logical Model -Relational Schema 15
43 Data Type and Details 16
v
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
CHAPTER FIVE PROJECT IMPLEMENTATION
51 Graphical User Interface Requirement 20
52 Graphical User Interface Normal BrowserWebsite 20
521 Login Page2 0
522 New Register Page (For New User) 22
523 Main Page 23
524 Update Personal Information Page - (For both Users andAdministrators) 26
525 Download Files (For both Users andAdministrators) 27
526 Upload File Page (For both Usersand Administrators) 29
527 Setup New Location Page (ForAdministrators) 30
528 Remove User Page (ForAdministrators) 32
529 File Management Page (ForAdministrators) 34
5210 Request New Locations Page (ForUsers) 35
5211 Update Location Information Page(For Users) 37
5212 Logout Function in Main Page (ForUsers and Administrator) 39
5213 Error Message Page (For Users andAdministrator) 39
CHAPTER SIX MAINTENANCE MANUAL
61 Software Installation 41
611 JAVA 2 Platform Standard Edition 41
vi
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
612 Structured Query LanguageInstallation 41
613 Java Database Connectivity 42
614 Tomcat 43
615 Secure Sockets Layer 43
CHAPTER SEVEN CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion 45
72 Future Directions 46
APPENDIX SOURCE CODE 47
REFERENCES146
vii
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
LIST OF FIGURES
Figure 1 System Architecture 6Figure 2 Use Case Diagram10Figure 3 Deployment Diagram of Online
Multimedia Communication System 12Figure 4 Entity Relationship Diagram 14Figure 5 Database Relational Schema 16Figure 6 Login Page - Registered Users 21Figure 7 New Register Page (For New User) 22Figure 8 Main Page (For Administrator) 24Figure 9 Main Page (For Users) 25Figure 10 Update Personal Information Page
(For both Users and Administrators) 27Figure 11 Download File Page (For both Users
and Administrators) 28Figure 12 Upload Files Page (For both Users
and Administrators) 30Figure 13 Setup Locations Page (For
Administrators) 32Figure 14 Remove User Page (For
Administrator) 33Figure 15 File Management Page (For
Administrators) 35Figure 16 Request New Locations Page (For
Users) 37Figure 17 Update Locations Page (For Users) 38Figure 18 Error Message Page (For Users and
Administrator) 40
ix
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
CHAPTER ONE
INTRODUCTION
11 Purpose of This Project This project is a web-based application that
provides a friendly and simple interface to let users
easily upload and download their multimedia files ordered
by locations The records are shared with not onlyauthorized users but also with administrators to the site
The project includes two parts one is a normal web
browser which uses HTML (Hyper Text Markup Language) as
the basic interface language The other one is server The
users can upload download and modify their files to
server and modify their personal information on the siteAll the information is stored in a MYSQL database andretrieved by JSP using JDBC or JSTL
Online Multimedia Communication System is an easy to
use web-based application Everyone knows how to use a
web browser so they can login to upload their multimedia
files or view the files on Download File page which
other users uploaded to server
12 Scope of Project121 Deliverables
The project has produced the following artifacts
1
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
1 A web application project directory organized according to the standard layout described inTomcat (httpjakartaapacheorgtomcat)
2 Java build file that compiles all java code and
generates javadoc
3 Javadoc for source code developed for system4 SQL creation scripts that create the database
5 Project report containing various UML diagrams
such as class diagrams use case diagrams
deployment diagrams etc
122 Function of Software ProductsThis system allows the users to modify and update
information from a normal web browser Users also uploadand download multimedia files to share Business andfamilies want to share their photos videos and audio
recordings
13 Significance of the Project We live in a global society where communications with
family and business associates must be maintained across
time zone and national boarders This project meets the
challenge of providing user-friendly interfaces to shared
data Online Multimedia Communication System makes use of
current technologies to increase reliability and
2
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
efficiency in the creation and execution of real-life
proj ects
14 Definition and AbbreviationsOMCS - Online Multimedia Communication SystemHTML - Hyper Text Markup LanguageHTTP - Hyper Text Transfer Protocol the clientServer
protocol that define how messages are formatted and
transmitted on the World Wide WebHTTPS - The secure version of HTTP provides authentication
and encrypted communicationJava - An object oriented language developed by Sun
Microsystems Java programsJavaScript - A scripting language that is widely supported
in Web browsers and other web toolsJava Servlet - A Java application that runs in a Web
Server and provide server-side processing typicallyto access a database
JDBC - Java database Connectivity A programming interfacethat lets Java applications access a database via theSQL language
JSP - Java Server Page An extension of the Java servlet technology from Sun displays dynamic content on theWeb Page
MySQL - Structured Query Language
3
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-
AVI - Audio Video Interleave The file format forMicrosofts Video for Windows standard
15 Organization of the Documentation The remaining sections of this document will be
organized as follows Chapter 2 introduces the
architecture of Online Multimedia Communication System
Chapter 3 is the software requirement specification (SRS)
Chapter 4 illustrates the database design Chapter 5
presents the project implementation Chapter 6 is the
maintenance manual Chapter 7 contains conclusions and
future directions
4
CHAPTER TWO
ONLINE MULTIMEDIA COMMUNICATION SYSTEM
ARCHITECTURE
In this chapter I will briefly introduce this
project OMCS implements a web system that provides an
environment for users to store and share their multimedia
files The system is a 3-tier-distributed architecture
that displays the user interface to a web browser using
JSP The middle tier is the Apache Tomcat web server that
handles requests from the client browser and provides
access to the third tier MySQL via JDBC
The web application executes a user command
bull User types a URL in web browser
bull - Request is transmitted to web server via HTTPS
protocol
bull Web server response to the request and executes
from a JSP page and loaded by the JSP engine
bull Java business logic communicates with database
via JDBC
bull JSP generates custom HTML documents or generates
custom WML documents and sends them back to the
user via the HTTP protocol
5
The user interface components are built by using HTML
60 forms HTTPS frames and JavaScript The application
is implemented using Java Server Pages (JSP) JSP was used
because it can use java business logic and provides a
common way for programs to interface with java containers
JSP is an extension of Java Servlet technology Typically
a Java Servlet can do the same tasks as JSP however JSP
makes it easy to mix static HTML with Java code
The database choice available to OMCS is MySQL MySQL
is a real multi-user database and free Also the
availability of the JDBC driver for MySQL is the most
important reason to choose it Moreover the same code
could be used to link with another version of MySQL
database by changing the JDBC driver thereby making it
database independent
21 Software Interfaces
bull Internet browser Netscape or Internet Explorer
bull Operating system Windows 98Me2000XP or
UnixLinux
bull Database MySQL
bull Compiler JDK 14
bull Language HTML JAVA JavaScript JSP JSTL
bull Database connector JDBC
7
JSP ContainerWeb server Jakarta Tomcat
bull Connect Protocal Secure HyperText Transfer
Protocal
8
CHAPTER THREE
SOFTWARE REQUIREMENTS SPECIFICATION
31 Introduction
Online Multimedia Communication System is a project
aimed at providing people the ability to upload and
download their multimedia files These users can modify
and view the site from a normal web browser and also
share the event files to other users
32 Overall Description
321 Product Perspective
Online Multimedia Communication System is web based
The interfaces are via Internet
The hardware interface requirement is that it must
run on the existing web servers The software interface
requirement is that it must support current versions of
Netscape and Internet Explorer The communications
interface requires support for Hyper-Text Transfer
Protocol by SSL (HTTPS)
9
322 Product Functions
Figure 2 Use Case Diagram
10
323 Product ArchitectureThe system contains three main parts of architecture
client side machine web server and database(1) Client side machine It requires having Internet
Brower and Internet connection This machine can connect
to web server by HTTPS protocol
(2) Web Server This project uses Linux 90 as the
operating system and Tomcat web server It establishescommunication between server and client machine and also
between server and database Java servlet is executable in
the server
(3) Database MySQL database is used in this project
To connect database we use Java Servlet to control when
to access the database and which information to access
11
Figure 3 Deployment Diagram of Online Multimedia Communication System
12
CHAPTER FOUR
DATABASE DESIGN
41 Data AnalysisThe data for designing and implementing the schema of
the database depends on properties of user In designing
the schema for the OMCS database four distinct parts have
been identified The first includes file part which
includes file name file path location id size created
date create time last access date last access time and
user id The second includes user id user name and user
password which would always be encrypted before storage
All the entities and attributes are detailed in Figure 5
13
PASSWORD
CZZ^ffectdate
Figure 4 Entity Relationship Diagram
14
There are some things one may not see from the E-R
Diagram and I will explain more The field of USERID in
both file and location has to match For example USER_A
owns LOCATION_A and LOCATION_B For all files owned by
USER_A must belong to either LOCATION_A or LOCATION_B
There is a function Remove User for administrator
When an administrator removes a user all locations and
files which belong to that user will automatically
belong to administrator
42 Database Schema Logical Model - Relational Schema
The conceptual model ER diagram maps into the
following relational table design In the following
tables underlined fields indicate the primary key
15
Field Names of Table USER
USERID FIRSTNAME LASTNAME MIDDLENAME
EMAIL PASSWORD ADDRESS TELEPHONE
GENDER ROLE STATUS
Field Names of Table LOCATION
LOCATIONID LADDRESS LTELEPHONE DESCRIPTION
EFFECTDATE STATUS USERIDlaquoFKraquo
Field Names of Table FILE
FILENAME FILEPATH LOCATIONIDlaquoFKraquo SIZE
CREATEDDATE CREATEDTIME LASTACCESSDATE LASTACCESSTIME
USERIDlaquoFKraquo
Field Names of Table FUNCTION
FUNCTlONID FUNCTIONNAME FUNCTIONPATH ROLE
Figure 5 Database Relational Schema
43 Data Type and Details
The logical model established the following detailed
design in MySQL database The following tables describe
data type length primary key and null or non-null keys
16
Table 1 Structure of Table USER
Filed Type Null Key Default ExtraUSERID VARCHAR(50) PRI
FIRSTNAME VARCHAR(50)
LASTNAME VARCHAR(50)
MIDDLENAME VARCHAR(50) Yes NULL
EMAIL VARCHAR(50)PASSWORD VARCHAR(50)ADDRESS VARCHAR(100) Yes NULL
TELEPHONE VARCHAR(30) YES NULL
GENDER CHAR(1) YES NULL
ROLE CHAR(1) YES NULL
STATUS CHAR(1)
17
Table 2 Structure of Table LOCATION
Field Type Null Key Default Extra
LOCATIONID VARCHAR(6) PRI
LADDRESS VARCHAR(100) YES NULL
LTETEPHONE VARCHAR(30) YES NULL
DESCRIPTION VARCHAR(200) YES NULL
EFFECTDATE DATE YES NULL
STATUS CHAR(l)
USERID VARCHAR(50) FK
Table 3 Structure of Table FUNCTION
Field Type Null Key Default
FUNCTIONID VARCHAR(6) PRI
FUNCTIONNAME VARCHAR(100)
FUNCTIONPAGE VARCHAR(100)
ROLE CHAR(1)
18
CHAPTER FIVE
PROJECT IMPLEMENTATION
OMCS is designed to perforin 7 different functions for
administrator and 6 different functions for users Refer
to Figure 2 is the Use case Diagram of this project
51 Graphical User InterfaceRequirement
User interfaces for the Online Multimedia
Communication System are designed as HTML pages The
contents are generated dynamically by JSP in response to
the users requests OMCS GUI is an easy to use system
The GUI is written using Hyper Text Markup Language (HTML)
Version 60 forms The OMCS GUI is executable under
Internet Explorer 50 or greater The following
sub-section explains the GUI functions and details
52 Graphical User Interface Normal Browser Website
521 Login Page
This page is the first page that all the users see
when they enter OMCS This page offers the login function
and a link to register new account (1) Registration This
link is for a new user who want to register new account in
OMCS By click this button user will be link to Register
page (2) Login name amp Password In these two boxes
20
current users can fill out their Login name and Password
By click Submit button it will submit the Login name and
password by HTTPS to server and processing login servlet
The system will forward current user to Main Page according users role which is administrator or user
He Edit View Favorites Toots Help t -al
Back rsquo (sect | ^Search gjFwirites ^Heds |8|regS 0[rsquoreg 0 reg rsquo $
SearchthaWeb [ [PSesrch If j Address |Q httpsomcsiascsusbedu8 lsquo43ray projectloginjsp a tmterdquo
Login name
Password [
Register a new account
- j Warningpis system must rathe used forsharing copyrighted materials uiiless you have writen permission to republish them s bull
dOone
Figure 6 Login Page - Registered Users
21
522 New Register Page (For New User)The New Register Page allows new users to fill out
some personal information included user_id and password
If the user id exists system will show the error message
in the current page The user can try another user id If
there is some other errors after user click Submit
button system will responses the error message back to
current page
tFile-Edt -View- Favorftes Tools Help - gt
-UBack raquo -4^ 0 jgf J ^Search (^Favorites ^Madia fe) pound3 ^Search the Web |pSearch)x|Address httpsomc51ascsusbedu8443rayjraquorojectregisterJsp ~3 go | Links gt
Online MultimediaCnimmitiication System
Last Name
Confirm Password
Telephone
OMaleO Female
prtejtvj fFeSfeTj
Dore vdi
Figure 7 New Register Page (For New User)
22
523 Main PageThis page will display function according users role
There are 7 functions for administrators and 6 functions
for users These are functions of administrators
(1) Update Personal Information The browser automatically
goes to Update Personal Information Page (2) Download
Files The browser automatically goes to Download Files
Page (3) Upload Files The browser automatically goes to
Upload files page (4) Setup New Location for User The
browser automatically goes to Setup Locations page(5) Remove User Press this link will display all the
users who registered in the system Administrator can
remove users from system (6) File Management Press this
link will display the previous page of the current pageAdministrator can remove uploaded files from system
(7) Logout Press this link system will logout the current
user and forwards the page to Login Page
23
Figure 8 Main Page (For Administrator)
These are functions of users
(1) Update Personal Information This function is as the
same as administrator (2) Download Files This function
is as the same as administrator (3) Upload Files This
function is as the same as administrator (4) Request New
24
Locations The browser automatically goes to Request New
Locations Page (5) Update Location Information The
browser automatically goes to Update Locations Page (6)
Logout This function is as the same as administrator
login raquo Kan
TTepr llritirtneUserlD g
ViCI vpuuiidFirst Name
Update Personal Information 9
Last Name2Download Files g
3Upload Files Middle Name g
4Re que st New Locations E-Mail g
5Update Location Information Address gasdfsd
6Logout Telephone g
Gender Female
Role User
gSB
a
Figure 9 Main Page (For Users)
25
524 Update Personal Information Page - (For bothUsers and Administrators)
This page is linked from both Users and
Administrators Main Page After loaded current users
information displays in this page Beside the Login ID
current user is able to modify all the information
After current user modified by click submit button
the information will be updated in the system database If
there are errors they are not allowed by system The
error message will be shown on the top of this page If
there are session errors the page will be forward to OMCS
ErrorMessage Page
After current user finished updating personal
information he or she can click the link Main Function
which is on the bottom of this page to go back to Main
Page
26
JOnLme Multimedia Communication System - Microsoft Internet Explore^ L jglp1B81BI1BBy -y - y r s X L ___ _
1 bull -gt r i ~ 7 v bdquo )) J-Il- X - bullrsquo _______ -j^creaj^l^j httpsfomcs lascsusb edu 8443ray jrojectUpdatePersonai ]spuseritj=g uMtsip
raquo Xiin raquo Update 5erslaquo
it J JHHH
Login ID Id 1
First Name Is 1Middle Name L 1Last Name la 1
Password | f
Confirm Password | 1
Address Igasdfsd |
Telephone Is JE-Mail Is iGender OMale reg Female
Main Function
H
^lsquoDcce
Figure 10 Update Personal Information Page (For both Users and Administrators)
525 Download Files (For both Users and Administrators)
After the user clicks Download Files link on Main
Function page the user goes to the Download Files page
Users and Administrators can view all multimedia files in
the system on this page and also save these event filesto local machine
27
It also displays the owner of these files so user
can easy to know who share those events with them
After current user finished updating personal
information he or she can click the link Main Page
which is on the bottom of this page to go back to Main
Page
Figure 11 Download File Page (For both Users and Administrators)
28
526 Upload File Page (For both Users andAdministrators)
Upload File Page allows user to upload their files by
different locations There are two parts in this page One
is to select a location and the other is to upload files
The locations option lists all locations which
belong to the current user After user selects one the
system will save the location ID in session User can
selects a file to be uploading to server After submit
the system will store the file to server and list the new
file information in the current page
In this system users can upload different types of
files but in the Download Files page only can play the
AVI format For the other files such as photos audios
and other type of video files user has to save those
files in local machine for viewing or playing User and
Administrator can keep uploading files as many as he or
she wants
The information displayed on the right is current
users personal information There is Main Function link
in the bottom of web page User can click the link and
link back to the Main Function page
29
Figure 12 Upload Files Page (For both Users and Administrators)
527 Setup New Location Page (For Administrators)Setup New Location Page allows administrators to
modify all users location information After users applynew locations locations status initially setup as nonshyactive Only until administrator active those locations
30
users will be able to upload event files for those
locations
In the location selection it shows description of
these locations Administrator can modify all the data for
this location beside location ID Location ID is given
when user applies new location by system
There are three statuses for locations New Apply
Active and Stop When user just applies new location
it displays New Apply in this page Administrator can
set it up as Active or Stop When a location is
Active user can upload files which belong to this
location
31
Figure 13 Setup Locations Page (For Administrators)
528 Remove User Page (For Administrators)Administrator can remove the current users in system
on this page In this page it shows the personal
information for all users Administrator can remove users
by click the button on the right
32
After administrator finish this page he or she can
go back Main Page by click Main Function link in the
bottom
Figure 14 Remove User Page (For Administrator)
33
529 File Management Page (For Administrators)
File Management Page allows administrators to manage
the files For example over month or years removing
files
The USERID field is read-only so administrator
cannot modify it here By click DELETE button system
will delete the file from database and server
Administrator can back to Main Function Page by click
Main Function link in the bottom of this page
34
Login raquo Xiin raquo tiaxage Files
File List
User ID - lsquo x 5 Filename UseilD Action |
U005_Apr_13_23_13000003^vi |x| First Name RAYMOND
22005_Apr_16_14_1603Q015avi |x 1 ma Last Name yang
3^C05_Apr_19_lJ_4regTO0012gif la1Middie Name yinwei
42005_MarJ0_18J1000002wi|peter ] E-Mail rawang927gmaiicom
52G05_Mar_lj_23_47000003avi |x 1 IdeiIetersquoS Address1200 Kendall Dr Sari Bernardino CA 92407
6^005_May_08_12_58000012ww|g trade| Telephone 9092221111
72005May_08_n_22000D08mw (g | Gender Male
Role Administrator
Main Function
Figure 15 File Management Page (For Administrators)
5210 Request New Locations Page (For Users)This function is for Users Any users are able to
apply newrsquolocations for uploading event files to shareUser can link to this page from Users Main Page
In this page Location ID is given by system and
it cannot be changed After User fills out the location
35
information and click submit That information will be
saved into database The web brower will stay in the current page with new location ID and user can apply as
many locations as he or she needed
After submit that information the location record
will be stored in database as New Apply User can update
the information in Update Location Page It would not be
show in the upload file function until administrator set
this location as Active
User can go back to Main Page by click Main
Function link in the bottom of this page
36
Figure 16 Request New Locations Page (For Users)
5211 Update Location Information Page (For Users)
Update Location Page allows users to update their
location information User have to select one of his or
her location from the top button which shown as Send
Location In the option area it shows the description of
each location User has to click the button to change the
locations
After that the location information will be
displayed below this field and user can change them The
37
location ID and status of the location are not able tochange by user Only administrator can change Status
After user modified the information he or she can
click Update button to update new information to server
The information will be changed right away After finished
updating user can go back to Main Page by click Main
Function link below
Figure 17 Update Locations Page (For Users)
38
5212 Logout Function in Main Page (For Users andAdministrator)
In the Main Page of User and Administrator there is
a Logout link for both of them After logout users will
be forward to Login Page automatically If the users
need to go back to this system he or she has to login
from Login Page again
5213 Error Message Page (For Users and Administrator)
In Online Multimedia Communication System if there
are system errors such as session errors or attributes
errors system will forward the current user to Error
Message Page In error message page it displays error
message from system and where it is from Users may have
to re-login in to the system
39
Figure 18 Error Message Page (For Users and Administrator)
40
CHAPTER SIX
MAINTENANCE MANUAL
System maintenance is an important step to ensure
that the system runs smoothly and meets the expectation of
the users In this project there are 3 major issues
Software Installation Variables Modification and OMCS
Installation
61 Software Installation
OMCS requires MYSQL TOMCAT and JDBC to run The
following will detail the installation of these software
packages
611 JAVA 2 Platform Standard Edition
JAVA 2 Platform Standard Edition (J2SE) is the
compiler program for JSP programs and the TOMCAT Container
requires it First of all we go to
httpjavasuncomproductsarchivej2sel4l_07 to
download SDK Windows (all languages including English)
and then install it
612 Structured Query Language Installation
Structured Query Language (MySQL) is the database
system we use in the OMCS and it is free Because it also
provides JDBC to easily connect by JAVA program thus it
is good choice for designing this project The
41
installation of MYSQL 323 is included in Linux 90 We
also can download it from Internet at
httpwwwmysqlcomdownloadsmysql-323html If users
download the compress file from Internet please unzip the
file and install it Second in Linux command we type
gt etcinitdmysqld start
It starts MySQL in server Third we have to add
etcinitdmysqld start into the file rclocal It
will start MySQL every time when we restart linux server
Forth we run MySQL on server to edit database by typing
gt mysql javatest -u javauser -p userdatabase
Enter passwordmysql_password
After that we can try to input following command
mysqlgt select from user
mysqlgt exit
gtThen we have already installed MYSQL and its working asexpected
613 Java Database ConnectivityThe API used to execute SQL statement is different
for each database engine Java programmers however arebecause they free from such database portability issues
They have a single API the Java Database Connectivity API(JDBC) thats portable between database engines The JDBC
42
library provides an interface for executing SQL statements
It provides the basic functionality for data access A
number of drivers are available for MySQL and information
about this can be obtained at the MySQL homepage at
httpwwwmysqlcomdownloads under JDBC For our
purpose we will use the MySQL driver which is a Type-4
JDBC driver that is under the GNU Library License
614 TomcatTOMCAT is one of the Jakarta apache projects it is a
JAVA container to process JSP programs and construct a web
server for static web pages First of all we go to
httpapachemirrorcentralcomdistjakarta
tomcat-4binaries to download the file tomcat-4118zip
and extract it to hard driver Also we copyCtomcatbinstartupbat and shutdownbat to the desktop as shortcut in order to easily start and shut down tomcat
615 Secure Sockets LayerThe security of this web site is very important for
this project In this part we are going to show how to set
it up This system uses HTTPS by Java Secure Socket
Extension (JSSE) In TOMCAT server you have to setup some
configuration file to activate HTTPS There are some filesyou need to modify serverxml netfiltersh rclocal
and iptables
43
First we have to generate the key we can type
gt keytool -genkey -alias name -keystore pathandname
First the system will generate the key and store it
as the path and name you type above Second we have to
change the serverxml file We have to add connector for
https To do this we have to add redirectPort=8443 in
the connector Third we have to add a line iptables -A
INPUT -p top --dport 8443 -j ACCEPT so the system will
aceep the 8443 as connect port Fourth we add a line in
iptables file
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8443 -
syn -j ACCEPT
This line will open port 8443 as a TCPIP standard
for connection Fifth we add a line rootnetfiltersh
in rclocal file so after rebooting server it will run
set https as acceptable port for server
44
CHAPTER SEVEN
CONCLUSION AND FUTURE DIRECTIONS
71 Conclusion
In the project OMCS provides a perfect environment
for user to upload download and view all users event
files over web browsers The system uses Tomcat Web Server
running on Linux platform with MYSQL database I
implemented the system using JavaScript JSP HTML and
JSTL languages and I implemented the advanced presentation
feature within the browser using JavaScript All dynamic
contents are handled by JSP The main logic was written in
Java and a data Source was used to connect to the
database
Online Multimedia Communication System is an easy to
use system of a Web-based application Everyone knows how
to use a web browser so they can login to system and
upload download and view all users event file online
There are also some disabilities for Online
Multimedia Communication System First the location
cannot be removed from the database When a user applies a
new location the location record will be in database If
an administrator removes the user the administrator will
automatically own the locations
45
Second there is no way to create an administrator
The administrator cannot be created by this system The
new register persons will automatically setup as users
72 Future Directions
The possible improvements that can be made for OMCS
include the following
To make the graphical user interface friendlier OMCS
aims to provide a friendly user interface but there are
still many possibilities for improvements For example
adding an OMCS picture icons in each pages to make the
entire page richer Change the format of the tables such
as Register page
For more OMCS system can be fit for doing Security
Guard for future Nowadays web cam is very popular and
its functions are very well For myself my web cam is
lax When I it setup as Guard Mode if the image in
front of the video changed it records the images into a
video file in a fixed path If we can change the Upload
Page by automatically upload from this folder this system
can become a security guard system for users
In future developments the system will be more
flexible to be installed for various places
46
APPENDIX
SOURCE CODE
47
File ListLoginjspRegisterjspregisterFtesuItl jspMainjspUpdatePersonaljspDownloadFilejspUploadFilejspSetupLocationsjspRemoveUserjspFileManagementjspRequestLocationjspRequestLocationResultjspUpdateLocationjspUpdateLocationResultjsplogoutjspLoginServletjavaRegisterServletjavaConstantsjavaUserjavaFilesjavaLocationjavaupdate_personjavaUploadFileSelectLocalServIetjavaUploadFileServletjavaSetupLocationSelectLocalServletjavaSetupLocationServletjavaRemoveUserServletjavaFileManagementServletjavaUpdateLocationSelectLocalServletjavaUpdateLocationServletjavaRequestLocationServletjava
48
Filename loginjsplt include file=RemoveCachejsp gtlthtmlgtltheadgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtlt
clean the values of the parameters of session try sessionremoveAttribute(useridjcatch(Exception exc)
responsesendRedirect(loginjsp)
gtctable align=center border=1ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=text name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtlttrxtd align=center class=OmcsTitlegt
ltpxinput type=submit value=Submit ciass=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtlttrxtd class=OmcsTitlegt
ltform method=POST action=registerjspgtltp align=center ciass=OmcsTitlexbrgtRegister a new accountltbrxbrgt cinput type=submit value=Registration name=B2 class=ButtonTextgt
ltpgtltformgt
lttdxtrgtlttabIegtltbodygtlthtmlgt
49
Filename registerjsplt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtlttitlegtOMCS Login Page (CSUSB)lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjspldquo gtlt
clean the values of the parameters of session try session removeAttribute(userid)catch (Exception exc)
responsesendRedirect(loginjsp)
gtlttable align=center border=1 ldquo cellspacing=O width=600gtlttrxtdgt
lttable align=center border=0 cellpadding=1 width=100 class=OmcsTitlegt ltform method=POST action=logingt
lttrxtd align=center class=OmcsTitlegtltbrxpgtLogin nameltinput type=ldquotext name=Userid id=Userid
size=20xpgtlttdxtrgtctrxtd height=25 align=center class=OmcsTitlegt
ltpgtPasswordampnbspampnbspampnbspltinput type=password name=p_wordid=p_word size=20xpgt
lttdxtrgtctrxtd align=center class=OmcsTitlegt
cpxinput type=submit value=Submit class=ButtonTextxpgtlttdxtrgt
ltformgtlttablegt
lttdxtrgtctrxtd class=OmcsTitlegt
cform method=POST action=registerjspgtcp align=center class=OmcsTitlexbrgtRegister a new accountcbrxbrgt cinput type=submit vaIue=Registration name=B2 class=ButtonTextgt
cpgtcformgt
ctdgtctrgtctablegtcbodygtchtmlgt
50
Filename registerResuItl jsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page contentType=texthtml gtlt include fiIe=RemoveCachejsp gtlthtmlgtltheadgtlttitlegtOMCS Registation Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gtltbody onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gtlt if (sessiongetAttribute(success)equals(OK)) gtlttable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtNew Register Pageltpxtdxtrxtablegtctable align=center border=0 cellpadding=1 width=60 class=OmcsTitlegt
ltform method=POSTrdquo action=registergtlttr valign=middlegt
lttd width=20gtFirst Namelttdgtlttd width=80xinput type=text name=fname id=fname size=20
value=lt=(sessiongetAttribute(fname)equals())sessiongetAttribute(fname)toString ()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtLast Namelttdgtctdxinput type=text name=lname id=lname size=20
value=lt=(sessiongetAttribute(lname)equaIs())sessiongetAttribute(lname)toString()gtgtlttdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtMiddle Namelttdgtlttdxinput type=text name=mname id=mname size=20
value=lt=(sessiongetAttribute(mname)equals())sessiongetAttribute(mname)toStri ng()gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20gtUsernamelttdgtlttdxinput type=text name=userid id=userid size=20
value=lt=(sessiongetAttribute(userid)equals())sessiongetAttribute(userid)toString( )gtxtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20ldquogtPasswordampnbsplttdgtctdxinput type=password name=password id=password size=20xtdgt
lttrgt
51
ctr bgcolor=E3BEE9gtlttd height=2 colspan=ldquo2xtdxtrgtlttr valign=middlegt
lttd width=20 nowrapgtConfirm Passwordlttdgtctdxinput type=password name=password_c id=password_c
size=20xtdgtlttrgtlttr bgcolor=E3BEE9ldquoxtd height=2 colspan=2xtdxtrgtlttr valign=middlegt
lttd width=20 gt Add ress lttdgtctdxinput type=text name=address id=address size=20
value=c=(sessiongetAttribute(address)equals())sessiongetAttribute(address)toSt ring()gtxtdgt
lttrgtctr bgcolor=rdquoE3BEE9xtd height=2 colspan=2ldquoxtdxtrgtlttr valign=middlegt
lttd width=20gtTelephonelttdgtctdxinput type=text name=phone id=phone size=20
vaIue=c=(sessiongetAttribute(phone)equals())sessiongetAttribute(phone)toString()gtgtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtE-Mailctdgtctdxinput type=text name=ldquoemail size=2O
value=c=(sessiongetAttribute(email)equaIs())sessiongetAttribute(email)toString()gtgtctdgt
ctrgtc String checkedMale = String checkedFemale =
String temp =(sessiongetAttribute(gender)equals())sessiongetAttribute(gender)toString()
if (templength() = 0) checkedMale = (tempequals(male))checked checkedFemale = (tempequals(female))checked
gt
ctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdxtrgt ctr valign=middlegt
ctd width=20gtGenderctdgtctdxinput type=radio name=gender id=gender value=male
c=checkedMaleraquoMalectdgtctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt ctr valign=middlegt
ctd width=20gtampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspampnbspctdgt
ctdxinput type=radio name=gender id=gender valuer femalec=checkedFemaleraquoFemalectdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt ctr valign=middlextd width=20 colspan=2gt
cinput class=ButtonText type=ldquosubmit value=Submitgt cinput class=ButtonText type=reset value=Resetgt
ctdgtctrgt
52
ltformgtlttablegtlt else gtctable align=center class=WebOutlook width=300gt
lttrxtdxp align=centergtCongratulationsltbrxbrgt Register Successltpxtdxtrgt
lttablegtltp class=OmcsTitle align=centerxa href=loginjspgtLogin Pageltaxpgtlt gtltbodygtlthtmlgt
53
Filename Mainjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlt7 include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtltlink href=WebOutlookcss rel=stylesheet type=textcssgtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Pragma CONTENT=NO-CACHEgtltheadgtltbody text=OOOOOO link=OOOOFF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtlth2 class=WebOutlook align=centergtOnline Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcsgtltcset var=p value=ray7gtltcset var=d value=OMCSgtltcset var=t value=FUNCTIONSgt
ltsqlsetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtlt
Get the values of the parameters from indexjsp by session
tryString userSession = (String)sessiongetAttribute(userSessionjString userid =
tryif (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)sessionsetAttribute(errorin catch for userid+e) if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(userid) else userid =
if (iuseridequals(userSession)) sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct1) responsesendRedirect(loginjspj
User current_user = Userfind(userid) sessionsetAttribute(LJD)requestgetContextPath() int counter = 0
gt
54
ltsqlquery var=resultgtSELECT FROM ltcout value=$tgt WHERE ROLE = lt=current_usergetRole()gt ltsqlquerygtbullstable align=center width=400xtr valign=middlegtlttd height=40xp align=center class=PageTitlegtMain Function Pageltpxtdxtrxtablegtltp class=displayLocationgtLogin raquo Mainltpgtbullstable width=94 border=1 height=ldquo291 gt
lttrgtbullstd width=59 height=285gt
ltdiv align=centergtUser Optionsltdivgtltdiv align=centergt
bullstable width=80 border=1gtltcforEach var=row items=$resultrowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=xtdgt
lta href=ltcout value=$row[2]7gtuserid=lt=useridgt style=text decorationnonex=++countergtlaquoscout value=$row[1]gtlaquosagt
laquostdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtlttd width=ldquo41 height=285gt
bullstable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
lttrgtlttd height=ldquo25 width=40 nowrapgtUser I Dlaquostdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgtbullstd x=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2ldquo colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd x=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=ldquo25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=ldquoE3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtbullstd height=25 width=40 nowrapgtAddresslttdgt
55
lttd x=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTeephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintln(Female)
gtlttdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(A))
outprintln(Administratorjelse if (current_usergetRole()equals(U))outprintln(User)else if (current_usergetRole()equals(N))outprintln(New User)else outprintln(Not a valuable user)
xtdgtlttrgt
lttablegtlttdgt
lttrgtlttablegtlt
catch(Exception exc)
requestsetAttribute(errorexception in Mainjsp) responsesendRedirect(loginjsp)
ltp align=centergtampnbspltpgt ltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
56
FilenameUpdatePersonaljsplt taglib prefix=ldquoc uri=httpjavasuncomjstlcore gt lt taglib prefix=sql uri=httpjavasuncomjstlsql gt lt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gt
lthtmlgtltheadxtitlegtOnline Multimedia Communication System lttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltheadgtltjspinclude page=adminheadinc gtltjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=OOOOFF onLoad=if (Navigator1 == navigatorappName) documenttorms[0]reset()gtlth2 align=center class=WebOutlookgtOnline Multimedia Communication Systemlth2gt lt page import=javasqi gtlt page contentType=texthtml gtlt
Get the values of the parameters from Mainjsp by session
String Logstatus = (String) requestgetAttribute(LogOkjString userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))String Logstatus=(String)sessiongetAttribute(LogOkjUser current_user = (User)sessiongetAttribute(userjUser current_user = Userfind(userid)sessionremoveAttribute(userid)sessionremoveAttribute(LogOKj
sessionsetAttnbute(requestedResource Mainjsp)gtctable align=center width=400xtrxtd height=40xp align=centerclass=PageTitlegtUpdate Personal lnformationcpxtdgtctrgtctablegtltp class=displayLocationgtLogin raquo Main raquo Update Personal lnformationltpgtctable class=LoginTable width=600 border=1 cellpadding=O ceIlspacing=O align=centergt
lttrxtdgtctable class=LoginTable width=100 height=1OO border=0
cellspacing=O ceIlpadding=O align=leftldquogtcform method=POST action=update_persongt
ctr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbspctdgt
ctd width=26 height=30 valign=middIegtLogin IDctdgt ctd width=64xinput type=text name=userid size=20
width=20 value=c outprintln(current_usergetUserid()) gt readonlyxtdgt ctrgt
57
lttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtFirst Name
lttdgtlttd width=64 cIass=OmcsTitle nowrapxinput
type=text name=first_name value=lt outprintln(current_usergetFirstName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtMiddle Namelttdgt
lttd width=64 class=rdquoOmcsTitle nowrapxinput type=text name=middle_name value=lt outprintln(current_usergetMiddleName()) gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtLast Namelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=last_name value=lt outprintln(current_usergetl_astName()) gt size=20xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtPasswordampnbsp lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=Ieft valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtConfirmPassword lttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=password name=password_c size=20xtdgt
lttrgtlttr bgcoior=E3BEE9xtd height=2ldquo colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtAddress lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=address value=lt outprintln(current_usergetAddress())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
58
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtTelephonelttdgt
lttd width=64 class=OmcsTitle nowrapxinput type=text name=telephone value=lt outprintln(current_usergetTelephone())gt size=20xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
lttr class=OmcsTitIe align=left valign=middle nowrapxtdwidth=10gtampnbsplttdgt
lttd width=26 height=30 valign=middlegtE-Mail lttdgtlttd width=64 class=OmcsTitle nowrapxinput
type=text name=email value=lt outprintln(current_usergetEmail())gt size=20xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgtlttr class=OmcsTitle align=left valign=middle nowrapxtd
width=10gtampnbsplttdgtlttd width=26 height=30 valign=middlegtGender lttdgtlttd width=64 class=OmcsTitIegt
ltif (current_usergetGender()equals(m)) gtcinput type=radio name=gender id=gender value=m checked
gtMalecinput type=radio name=gender id=gender value=fgtFemale
c else gtcinput type=radio name=gender id=ldquogender value=mgtMale cinput type=radio name=gender id=gender checked
value=fgtFemalec gt
ctdxtrgtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(error exc + Try to access UpdatePersonaljsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt ctrgt
ctd width=10 height=30 valign=middlextdgtctdxinput type=submit value=Submit class=ButtonTextxinput
type=reset value=Reset class=ButtonTextldquogtctdgtctd width=10xa href=rdquoMainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncaxtdgt ctrgt cformgt
59
lttablegtlttdxtrgtlttablegtlt gtltbodygtlthtmlgt
60
Filename DownloadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=FtemoveCachejsp gtlthtmlgtltheadgtlttitlegtDownload Files lttitlegtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[Ojreset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=pldquo value=raygtccset var=d value=OMCSgtccset var=t value=FILEgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc String saveDirectory =homerayprojectwebappvideo
Get the values of the parameters from indexjsp by session 7
String userid = try userid = (String) requestgetParameter(userid)String userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0 WHERE USERID = c=current_usergetUserid()
gtcsqkquery var=resultgtSELECT FROM ccout vaiue=$t7gtcsqlquerygtcform name=DownioadFile id=DownloadFile method=post action=DownioadFilejspgt ctable align=center width=400gtctrgtctd height=40gtcp align=center class=PageTitIegtDownIoad File Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Download Filescpgt ctable width=94 border=ldquo1 height=291gtctrgtctd width=59 height=285gt cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ccforEach var=row items=$resultrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyiebackground=lgtctdgt
61
cOBJECT ID=mediaPlayer CLASSID=CLSID22d6f312-b0f6-11d0-94ab-0080c74c7e95CODEBASE=httpsactivexmicrosoftcomactivexcontrolsmplayerennsmp2infcabVersion =5152701 STANDBY=Loading Microsoft Windows Media Player components TYPE=applicationx-oleobjectgt
ltparam name=FileName value=ltcout value=$row[1 ]gt type=videoaviwmv gt
cPARAM NAME=animationatStart VALUE=truegt cPARAM NAME=transparentatStart VALUE=falsegt cPARAM NAME=autoStart VALUE=falsegtltparam name=autorewind value=truegt cOBJECTgtcbrxa href=httpsomcsiascsusbedu8443ray_projectltcout
value=$row[1 ]gt style=text-decorationnonex=-H-countergtltcout value=$row[1 ]gtltaxbrgt
ltfont color=0033FFgtOwnerltcout value=$row[8]7xfontgtlttdxtrgtltcforEachgt
lttablegtltpgtampnbspltpgt
ltdivgtlttdgtctd width=41 height=285gt
ctable cellpadding=0ldquo cellspacing=0 border=0 cIass=OmcsTitle align=center width=95gt
lttrgtlttd height=25 width=40 nowrapgtUser IDlttdgtlttd gtlt=current_usergetUserid()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtFirst Namelttdgt ctd gtlt=current_usergetFirstName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtLast Namelttdgtlttd gtlt=current_usergetLastName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd gtlt=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Mailctdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgt
62
lttd gtlt=current_usergetAddress()xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25ldquo width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintIn(Malejelse outprintin(Femalej
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2gtlttdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorjelse if (current_usergetRole()equals(U))outprintln(Userjelse if (current_usergetRole()equals(Nj)outprintin(New User)else outprintln(Not a valuable user)
gtlttdgtlttrgt
lttabIegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)
sessionsetAttribute(ldquoerrorException in DownloadFilejsp) requestsetAttributeferrorException in DownloadFilejsp) responsesendRedirect(ldquoOMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgt
63
ltbodygtlthtmlgt
64
Filename UploadFilejsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=cldquo uri=httpjavasuncomjstlcore gtlt taglib prefix=ldquosql uri=ldquohttp7javasuncomjstlsql gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtltDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpload Files lttitlegtltmeta http-equiv=Content-Type content=ldquotexthtml charset=iso-8859-1 gtltMETA HTTP-EQUIV=Refresh CONTENT=60URL=httpsomcsiascsusbedu8443ray_projectUploadFilejspgtltMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtltscript language=JavaScriptgtltscriptgtclink href=WebOutlookcssrdquo rel=stylesheet type=textcssgtltheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0] reset() gtlth2 class=WebOutlook align=centergtOnIine Multimedia Communication Systemlth2gt ltcset var=h value=omcsgtltcset var=u value=raygtltcset var=l value=omcs7gtltcset var=p value=raygtltcset var=d value=OMCS7gtltcset var=file value=FILEgtltcset var=location vaIue=LOCATIONgt
ltsqIsetDataSource driver=commysqljdbcDriveruri=jdbcmysql$l$duser=$uamppassword=$pgtltTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideoint maxPostSize = 300 1024 1024 String Locationjd =(session getAttribute(ldquoLJDjequaIs(l))sessiongetAttribute(lL_ID)toString() int i = 0
Get the values of the parameters from Mainjsp by session 7String userid =String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
trytry
userid =(sessiongetAttribute(userid)equals())(String)sessiongetAttribute(userid)
catch (Exception e) if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj
65
catch (Exception e)
userid =(requestgetAttribute(userid)toString()length ()gtO)(String)requestgetAttribute(userid)user Session
if (useridequals(j)
sessionsetAttribute(ldquoerrorin catch for userid UploadFilejsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequaIs(userSession))
User current_user = Userfind(userid)String LJD = (String) sessiongetAttribute(L_IDj userid = current_usergetUserid()sessionsetAttribute(requestedResourceldquoUploadFilejsp) int counter - 0
gtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpload Files Pagecpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Upload Filescpgt ctable width=ldquo94 border=1 height=291gtcform name=Selectl_ocation id=SelectLocationldquo action=UpIoadFileSeIectLocalServlet method=postgt
cinput type=hidden name=userid id=useridldquo value=c=useridgtldquoreadonlygtcsqkquery var=resultgtSELECT LOCATIONID FROM ccout value=$locationgt WHERE USERID =c=current_usergetUseridOgt1 AND STATUS = W ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd colspan=2gt Select the current locations cSELECT NAME=L_IDgt
cOPTION value=ldquo SELECTEDgt-SELECT LOCATION- ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout value=$row[0]gtgtccoutvalue=$row[0]gt
ccforEachgtcSELECTgtcinput class=ButtonText type=submit value=Submitldquogt
ctdgtctrgtltgt
cformgtctrgtctd width=59 height=285ldquogt cdiv align=centergtFile Listcdivgt cdiv align=centergt
ctable width=80 border=ldquo1 gt ctrgt
ctd align=centergtLocation I Dctdgt ctd align=centergtFiienamectdgt
ctrgtcif (L_IDequals(j)
sessionsetAttribute(L_IDLJD) sessionsetAttribute(userid userid)
66
gtcsqkquery var=result_filegtSELECT FILENAME FILEPATH LOCATIONS FROM ltcout
value=$file7gt WHERE LOCATIONS = lt=L_IDgt ORDER BY LOCATIONS FILENAME
ltsqlquerygtltcforEach var=row items=$result_filerowsBylndexgt
lttr onMouseOver=thisstylebackground=CFDEF5onMouseOut=thisstylebackground=gt
lttd align=centerldquogtltcout value=$row[2]7gt
lttdgtlttdgt
lta href=ltcout value=$row[1 ]7gt style=text- decorationnonexcout value=$row[0]7xagt
lttdgtlttrgt
ltcforEachgtctrxtd
colspan=2x=(requestgetAttribute(error))=nullrequestgetAttribute(error)gtlttdxtrgt
cform name=UploadFile id=UploadFile action=UploadFileServlet method=POST ENCTYPE=muItipartform-datagt
ctrxtd colspan=2gtcinput type=file name=ldquofilename id=filename
accept=videoavi width=20 size=2O maxlength=100gtctdgtctrgtctr valign=middlextd colspan=2gtcinput class=ldquoButtonText type=submit value=Submitxinput
class=ButtonText type=reset value=Resetgtctdgtctrgt
cformgtc gt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2ldquoxtdxtrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd x=current_usergetLastName()xtdgt
67
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtMiddle Namelttdgtlttd x=current_usergetMiddleName()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=ldquo2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtE-Maillttdgtlttd gtlt=current_usergetEmail()xtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=l2lxtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtAddresslttdgtlttd gtlt=current_usergetAddress()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtTelephonelttdgtlttd gtlt=current_usergetTelephone()xtdgt
lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtGenderlttdgtlttd gtlt if (current_usergetGender()equals(m))
outprintln(Malejelse outprintlnfFemale)
xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=2xtdxtrgt
lttrgtlttd height=25 width=40 nowrapgtRolelttdgtlttd gtlt if (current_usergetRole()equals(Aj)
outprintlnCAdministratorj else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintlnfNot a valuable user)xtdgt
lttrgtlttablegtlttdgt
lttrgtctrxtd colspan=2 align=ldquocenterxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt else
sessionsetAttribute(errorThe session is not correct) requestsetAttributeferrorjThe session is not correct) responsesendRedirectfloginjspj
68
catch (Exception exc)sessionsetAttribute(errorOut from UploadFilejsp + LocationJd + userid + exc responsesendFtedirectCOMCSErrorMessagejsp)
gtltp aiign=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
69
Filename SetupLocationsjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sqlldquo uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiijavaio gtlt include fiie=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtSetup Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=location value=LOCATIONgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from indexjsp by session 7
String userid =String L_ID =String Locationjd =(session getAttribute(LJD)equals())sessiongetAttribute(L_IDjtoString()String userSession =(session getAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)
if (requestgetAttribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(useridj
else userid =if (useridequals())
sessionsetAttribute(errorin catch for userid Setuplocationsjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) userid = current_usergetUserid()
70
L_ID = (String) sessiongetAttribute(L_ID) sessionsetAttribute(SourcePageSetupLocationjava) sessionsetAttribute(requestedResourceSetupLocationsjsp) int counter = 0
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtSetup Locationsltpxtdxtrxtablegtltp cIass=dispIayl_ocationgtLogin raquo Main raquo Setup Locationsltpgt ctable width=94 border=1 height=291ldquogtltsqlquery var=resuitgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$locationgtltsqlquerygtcform name=SelectLocation id=SelectLocation action=SetupLocationsSelectLocalServIet method=postgt
cinput type=hidden name=userid id=userid vaiue=c=useridgt readonlygt ctrxtd coispan=2gt Select the current locations
cSELECT NAME=L_IDclass=linkTextgtcOPTION SELECTEDgt~SELECT LOCATION-
ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
value=$row[1]gtccforEachgtcSELECTgtcinput class=ldquoButtonText type=submit value=Submitgt
ctdgtctrgtcformgtctrgtctd width=59 height=285 align=centergtLocation Information
ltif (L_IDequals())sessionsetAttribute(L_IDLJD) sessionsetAttribute(useriduserid)Location nowjocal = LocationfindLocation(L_ID)
gtcsqkquery var=result_locationgtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ORDERBY LOCATIONIDcsqlquerygtcform name=SetupLocations id=SetupLocation action=SetupLocationsServlet method=post onSubmit=javascriptsetLocationlD()gt
cdiv align=centergtctable width=80 border=1 class=linkTextgt
ccforEach var=row items=$result_locationrowsBylndexgt ctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=this style background=gtctd width=45gtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout value=$row[0]gt readonlygtctdgt ctrgtctr onMouseOver=thisstylebackground=lCFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= ccout value=$row[1]gtxtdgt
71
lttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONEldquo
VALUE = ccout value=$row[2]7gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE = ccout value=$row[3]gtlsquogtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE = ccout value=$row[4]gtgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSctdgtc String n_status = w_status = s_status =
if (nowJocalgetStatus()toString()equaIs(Nj) n_status =checked
else if (nowJocalgetStatus()toString()equals(Wj) w_status= checked
else if (nowJocalgetStatus()toString()equals(S)) s_status= checked
gtctdxfont face=Times New Roman size=-2 color=000000gt cinput type=radio name=STATUS id=STATUS VALUE=N
c=n_statusraquoNew Applycbrgtcinput type=radio name=STATUS id=STATUS VALUE=W
c=w_statusraquoActivecbrgtcinput type=radio name=STATUS id=STATUS VALUERS
c=s_statusraquoStopcfontgtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =
ccout value=$row[6]gt readonlygtctdxtrgtctr bgcolor=ldquoFF0033xtd height=3 colspan=2xtdxtrgt ccforEachgtctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit value=Updatexinputclass=ButtonText type=reset value=ldquoResetgt
ctdxtrgtctablegt
cdivgtcformgt
72
lt gt ctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd heights25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=ldquo40ldquo nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equaIs(mj)
outprintIn(Malejelse outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRoIectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administratorj
73
else if (current_usergetRole()equals(U))outprintlnfUser)else if (current_usergetRole()equals(N))outprintln(New User)else outprintInfNot a valuable user)
gtlttdgtlttrgt
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=lt=useridgt
style=text-decorationnonegtMain Functionltaxtdxtrgtlttablegtlt
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
catch (Exception exc)sessionsetAttribute(errorOut from SetupLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageSetupLocationsjspjresponsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmigt
74
Filename Ftemovellserjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtRemove Userlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator = navigatorappName) documenttorms[0]reset() gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=t value=USERgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from indexjsp by session 7
String userid =String userSession = (String) sessiongetAttribute(userSessionj try
tryif (requestgetParameter(useridjtoString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )if (requestgetAttribute(userid)toString()iength()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgtSELECT FROM ccout value=$tgtcsqlquerygtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRemove User Pagecpxtdxtrgtctablegt cp cIass=displayLocationgtLogin raquo Main raquo Remove Userscpgt ctable width=76O border=1 align=centergtctrxtd align=centergtUser lnformationctdxtrgt ctrgt
75
lttd width=80 align=centergt ctable width=100 border=0gt
ctr class=firstRow align=centergt ctdgtUser IDctdgt ctdgtFirst Namectdgt ctdgtLast Namectdgt ctdgtE-Mailctdgt ctdgtAddressctdgt ctdgtActionctdgt
ctrgtcint c = 0 String RecordCtrString zero = 000String RecordiD =gt
ccforEach var=row items=$resultrowsBylndexgt c RecordCtr = lntegertoString(c++)
RecordiD = zerosubstring(03-RecordCtrIength()) +RecordCtr
gtcform method=POST action=RemoveUserServlet
name=ldquoforc=Record I Dgtgtctr class=OmcsTitle onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=ffffccgtcinput type=hidden name=userid id=userid value=c=useridgt
size=10gtctd height=18gtcinputtype=hidden name=deleteid id=deleteid value=ccout
value=$row[0]gt size=10gtccout vaiue=$row[0]gtctdgtctdxinput type=hidden name=RecordlD id=RecordlD
value=c=RecordlDgt readonlyxcout value=$row[1 ]xtdgtctd width=10xcout value=$row[2]xtdgt ctd width=10xcout value=$row[4]xtdgt ctdxcout value=$row[6]gtctdgtctd align=centerxinput name=StatusAction type=submit
class=OmcsTitie id=ldquoStatusAction value=Removextdgtctrgt
cformgtctr bgcolor=ldquoE3BEE9xtd height=2 colspan=6gtctdgtctrgt ccforEachgtctrxtd aiign=center colspan=6xa href=Mainjspuserid=c=useridgt
styie=text-decorationnonegtMain Functioncaxtdxtrgtctablegt
ctdgtctrgt
ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjspj
76
catch (Exception exc)sessionsetAttribute(error exc + Try to access RemoveUserjsp+userid) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
77
Filename FileManagementjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtFile ManagementlttitlegtcMETA HTTP-EGUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcheadgtcbody text=OOOOOO link=0000FF onLoad=if (Navigator == navigatorappName) documentforms[0]reset()gtch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=fiie value=FILEgt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaxmum 3 files 5M per filesint maxPostSize =3 5 1024 1024
Get the values of the parameters from Mainjsp by session 7 String userid =
try
String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try if (requestgetParameter(userid)toString()Iength()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e )
if (requestgetAftribute(userid)toString()length()gt0) userid = (String)requestgetAttribute(userid)
else userid =if (useridequals(j)
sessionsetAttribute(errorin catch for userid FileManagementjsp) responsesendRedirect(OMCSErrorMessagejspj
if (useridequals(userSession))
User current_user = Userfind(userid) int counter = 0
gtcsqkquery var=resultgt
78
SELECT FROM ltcout value=$filegt ORDER BY FILENAMEltsqlquerygtctable align=center width=400gtctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtFile Managementcpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Manage Filescpgt ctable width=94 border=1 height=291 gt
ctrgtctd width=59 height=285gt
cdiv align=centergtFile Listcdivgt cdiv align=centergtctable width=80 border=1 gt
ctrgtctdgtFilenamectdgtctdgtUserlDctdgtctdgtActionctdgt
ctrgtccforEach var=row items=$resultrowsBylndexgt cform name=ldquoFileManagementc=countergt
action=FileManagementServiet method=getgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstyIebackground=gtctd width=84gtcinput type=hidden name=filename id=filename
value=ccout value=$row[0]gtgtcinput type=hidden name=path id=path value=ccout
value=$row[1 ]gtgtcinput type=hidden name=userid id=userid
value=c=useridgt readonlygtca href=ccout value=$row[1 ]gt style=text-
decorationnonegtc=++countergtccout vaiue=$row[0]gtcagtctdgtctd width=8gtcinput type=text name=ownerid id=ownerid
size=10 value=ccout value=$row[8]gtgtctdgtctd nowrap width=8gtcinput type=submit value=DELETE
name=DELETEgtcinput type=hidden name=dfile id=dfile
value=c=sessiongetAttribute(ldquodfile)gtgtctdgtctrgt
cformgtccforEachgt
ctablegtcpgtampnbspcpgt
cdivgtctdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=lsquo2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgt
79
ctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=cu rrent_user getLastN am e() gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctr bgcoIor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTeIephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Male)else outprintln(FemaIe)
gtctdgtctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2ldquogtctdgtctrgt ctrgt
ctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(Administratorj else if (current_usergetRole()equals(U))
outprintln(User) else if (current_usergetRole()equals(N))
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgt
ctrgtctrgtctd colspan=2 align=centergtca href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegt
80
else lt
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionsetAttribute(errorOut from FileManagementjsp + userid + exc) responsesendRedirect(OMCSErrorMessagejsp)
gtltp align=centergtampnbspltpgtltpgtampnbspltpgtltpgtampnbsp ltpgtltbodygtlthtmlgt
81
Filename RequestLocationjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtc taglib prefix=sql uri=httpjavasuncomjstisql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Locationlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gtcbody text=03ff00 link=0000FF onl_oad=if (Navigator -- navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l vaIue=omcsgtccset var=p vaIue=raygtccset var=d vaIue=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid = try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSession) if (useridequals(userSession))User current_user = Userfind(userid) sessionsetAttribute(SourcePageRequestLocationjsp) sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(requestedResourceRequestLocationjsp) sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400xtr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpxtdxtrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 ceilpadding=1 cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=O cellpadding=O align=leftgt
82
cform method=POST action=RequestLocationServletgtcinput type=hidden name=userid id=userid value=c=useridraquo
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgt ctd width=200 height=30gtLocation ID(CANNOT
CHANGE)ctdgtctdxinput type=text name=LOCATIONID size=20
width=20rdquo readonly value=c=newLocationlDraquoctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=ldquo30gtADDRESS ctdgtctd class=OmcsTitle nowrapxinput type=text
name=LADDRESS value= size=50 maxlength=100xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3gtctdxtrgt
ctr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtTELEPHONEampnbsp ctdgt ctd class=OmcsTitle nowrapxinput type=text
name=LTELEPHONE size=20 value= maxlength=30xtdgt ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ctr class=OmcsTitle align=left vaiign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtDESCRIPTION ctdgtctd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20 maxlength=200gtctdgt ctrgtctr bgcolor=E3BEE9xtd height=ldquo2 colspan=3xtdxtrgt
ctr class=OmcsTitie align=left valign=middle nowrapxtd width=30gtampnbspctdgtctd height=30gtEFFECT DATE ctdgtctd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value= size=20 maxlength=10xtdgt ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
cif (current_usergetRole()equals(Aj) gtctr class=OmcsTitle align=left valign=middle nowrapgt
ctd width=30gtampnbspctdgt ctd height=30gtSTATUS ctdgt ctd class=OmcsTitlellgt
cinput type=radio name=status id=statusvaiue=N checked gtNEW APPLY
cinput type=radio name=status id=statusvalue=WgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=SgtSTOPPED
ctdgtctrgtctr bgcolor=E3BEE9xtd height=ldquo2 coispan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
c~ ctr class=OmcsTitle align=left valign=middie nowrapxtdwidth=30gtampnbspctdgt
ctd height=30gtSTATUS ctdgt
83
ctd class=OmcsTitlegtcinput type=text readonly name=status id=status value=Ngtctdgt
ctrgtmdashgtc
else
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(Ioginjsp)
catch(Exception exc)
sessionsetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejsp)
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput type=submit value=Submit
class=ButtonTextgtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnoneldquogtMain Functionscagtctdgtctrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
84
Filename RequestLocationResuitjsplt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt page import=project gtlt page import=javautiljavaio gtlt page import=javasql gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlt include file=ConnectionsdatabaseConnectionsjsp gtlthtmlgtltheadxtitlegtRequest New Location Resultlttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtclink href=HelpU7WebOutlookcss rel=stylesheet type=textcssldquogtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutIookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=T value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATIONgtcsqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$pgtc
Get the values of the parameters from Mainjsp by session
String userid - try userid = (String) requestgetParameter(useridjString userSession = (String) sessiongetAttribute(userSessionj if (useridequals(userSession))User current_user = Userfind(userid)session setAttribute(SourcePage RequestLocation jsp)sessionsetAttribute(SourcePageBeforeLocationjString newLocationlD = LocationNewLocationlD() sessionsetAttribute(SourcePageAfterLocation)
gtctable align=center width=400gtctr valign=middlextd height=40xp align=center class=PageTitlegtRequest New Locationscpgtctdgtctrgtctablegt cp class=ldquodisplayLocationgtLogin raquo Main raquo Request New Locationscpgt ctable class=LoginTable width=600 border=1 cellpadding=1 ldquo cellspacing=1 align=centergt
ctrxtdgtctable class=LoginTable width=600 height=1OO border=0
cellspacing=Oldquo cellpadding=O align=leftgt
85
cinput type=hidden name=userid id=userid value=lt=useridraquo ltform method=POST action=RequestLocationServletldquogt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt lttd width=200 height=30gtLocation ID(CANNOT
CHANG E)lttdgtctdxinput type=text name=LOCATIONID size=20ldquo
width=2O readonly value=c=newLocationlDraquoctdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=leftldquo valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtADDRESS lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=LADDRESS vaiue=c=sessiongetAttribute(LADDRESS)gt size=50xtdgtlttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtTELEPHONEampnbsp lttdgtlttd class=OmcsTitle nowrapxinput type=ldquotext
name=LTELEPHONE size=20 value=c=sessiongetAttribute(LTELEPHONE)gtgtctdgt lttrgtlttr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgtctd height=30gtDESCRIPTION lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=DESCRIPTION size=20value=lt=sessiongetAttribute(DESCRIPTION)gtxtdgt
lttrgtlttr bgcoIor=E3BEE9xtd height=2 colspan=3xtdxtrgt
lttr class=OmcsTitle align=left valign=middle nowrapxtd width=30gtampnbsplttdgt ctd height=30gtEFFECT DATE lttdgtlttd class=OmcsTitle nowrapxinput type=text
name=EFFECTDATE value=lt=sessiongetAttribute(EFFECTDATE)gt size=20xtdgt lttrgtctr bgcolor=E3BEE9xtd height=2 colspan=3xtdxtrgt
ltif ( current_usergetRole()equals(Aj) gtlttr class=OmcsTitle align=Ieft valign=middle nowrapgt
lttd width=30gtampnbsplttdgt ctd height=30gtSTATUS lttdgtlttd cIass=OmcsTitlegt
lt String NewChecked = WorkChecked =StopChecked =
if(sessiongetAttribute(status)toString()equals(N)) NewChecked = checked
else if(sessiongetAttribute(status)toString()equals(W)) WorkChecked = checked
else if( sessiongetAttribute(status)toString()equals(S)) StopChecked = checkedgt
value=Nldquo NewChecked gtNEW APPLYcinput type=radio name=status id=status
cinput type=radio name=status id=status value=W WorkCheckedgtWROKING CURRENT
cinput type=radio name=status id=statusvalue=S StopCheckedgtSTOPPED
86
lttdgtlttrgtctr bgcolor=E3BEE9gtctd height=ldquo2ldquo colspan=3gtctdgtctrgt
c else gtcinput type=hidden readonly name=status id=status value=Ngt
lt Jelse
sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(loginjsp)
catch(Exception exc)
sessionSetAttribute(errorexc)responsesendRedirect(OMCSErrorMessagejspj
gt
ctrgtctd width=30gtctdgtctd height=30gtcinput class=ButtonText type=submit
value=Submitldquogtcinput class=ButtonText type=reset value=Resetgtctdgtctdgtca href=Mainjspuserid=c=useridgt style=text-
decorationnonegtMain Functioncagtctdgtlttrgtcformgtctablegt
ctdgtctrgtctablegtcbodygtchtmlgt
87
FilenameUpdateLocationjsplt page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtlt ll include file=ConnectionsdatabaseConnectionsjsp gtclDOCTYPE HTML PUBLIC -W3CDTD HTML 401 TransitionaIENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=stylesheet type=textcssgtcSTYLE type=textcssgtPmypar font-style roman color bluecSTYLEgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator1 == navigatorappName) documentforms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcs7gtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=locationldquo value=LOCATIONgt
csqksetDataSource driver=commysqkjdbcDriverurl=jdbcmysql$l$duser=$uamppassword=$p7gtc
Get the values of the parameters from Mainjsp by session 7 String userid =String L_ID =String Locationjd =(sessiongetAttribute(L_ID)equals())sessiongetAttribute(LJD)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSession)
try
try if (requestgetParameter(useridldquo)toString()Iength()gt0)
userid = (String)requestgetParameter(userid) catch (Exception e)if (requestgetAttribute(userid)toString()length()gt0)
userid = (String)requestgetAttribute(useridjelse userid = userSession
if (useridequals(userSession))User current_user = Userfind(userid) userid = current_usergetUserid()
88
LJD = (String) sessiongetAttribute(L_IDj sessionsetAttribute(SourcePageUpdateLocationjspj sessionsetAttribute(requestedResourceUpdateLocationjspj int counter = 0
gtltsqlquery var=resultgtSELECT LOCATIONID DESCRIPTION FROM ltcout value=$location7gt WHERE USERID= llt=current_usergetUserid()gt ORDER BY LOCATIONIDltsqlquerygtctable align=center width=400gt
ctr valign=middlegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgt
ctdgtctrgtctablegtcp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgtctable width=94 border=1 gtctrgtcform name=SelectLocation id=SelectLocationldquo action=UpdateLocationSelectLocalServlet method=POSTgt
ctd height=49 colspan=2gtSelect the current locationscinput type=hidden name=userid id=userid value=c=useridraquo
cSELECT NAME=L_ID class=linkTextgtcOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgtcOPTION value=ccout value=$row[0]gtgtccout
vaIue=$row[1]gtccforEachgt
cSELECTgtcinput class=ButtonText type=submit name=Submit1 value=Send
Locationgtctdgt
cformgtctrgt
csqkquery var=result_filegtSELECT FROM ccout value=$location7gt WHERE LOCATIONID = c=LJDgt ANDUSERID = c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygt
ctrgtctd width=59 height=285 align=centergt cdiv align=centergtLocation lnformationcdivgt
cform name=UpdateLocation id=UpdateLocation action=UpdateLocationServiet method=POSTgt
ctable width=80 border=1 class=linkTextgt c if (L_IDIength() gt 0 ampamp L_IDequals(-SELECT LOCATION-))
Location nowjocal = LocationfindLocation(LJD)gt
ccforEach var=row items=$result_filerowsBylndexgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONID
VALUE = ccout vaIue=$row[0]gt readonlygtctdgtctrgt
89
ctr onMouseOver=this style background=CFDEF5 onMouseOut=thisstylebackground=gt
lttdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
= lsquoltcout value=$row[1 ]gt maxlength=100xtdgtlttrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =ccout value=$row[2]gt maxlength=l30xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRIPTION
VALUE =ccout value=$row[3]gt maxlength=200xtdgtctrgtctr onMouseOver=thisstyiebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =ccout value=$row[4]gt maxlength=1 Oxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtSTATUSc String now_status = None
if (nowJocalgetStatus()toString()equals(Nj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(Wj)now_status = Active
else if (nowJocalgetStatus()toString()equals(Sj)now_status = Stop
gtctdxinput type=text name=STATUS id=STATUS VALUE
=lt=now_statusgt readonlyxtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtUSERIDctdgtctdxinput type=text name=USERID id=USERID VALUE =ccout
value=$row[6]gt readonlyxtdgtctrgt
ccforEachgtctr bgcoior=FF0033xtd height=3 colspan=2xtdgtctrgt ctr valign=middlextd colspan=2gt
cinput class=ButtonText type=submit name=submit2value=Updategt
cinput class=ButtonText type=reset value=Resetgt ctdgtctrgt
c gtctabiegt
90
ltformgtlttdgtctd width=41 height=285gt
ctable cellpadding=O cellspacing=O border=0 cIass=OmcsTitIe align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd gtc=current_usergetUserid()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd gtc=current_usergetFirstName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtMidde Namectdgt ctd gtc=current_usergetMiddleName()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd gtc=current_usergetEmail()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTeIephone()gtctdgt
ctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(mj)
outprintlnCMalejelse outprintlnCFemale)
gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(A))
outprintln(ldquoAdministrator) else if (current_usergetRole()equals(Uj)
outprintlnfUserj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgt
91
lttablegtlttdgt
lttrgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
styIe=text-decorationnonegtMain Functioncaxtdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejsp)
catch (Exception exc)sessionsetAttribute(errorOut from UpdateLocationjsp + Locationjd + userid +
exc)sessionsetAttribute(SourcePageldquoldquoUpdateLocationjsp) responsesendRedirect(OMCSErrorMessagejsp)
gtcbodygtchtmlgt
92
Filename UpdateLocationResultjsplt page contentType=texthtmi charset=iso-8859-1 Ianguage=java import=javasql gtlt page import=project gtlt page import=javautiljavaio gtlt taglib prefix=c uri=httpjavasuncomjstlcore gtlt taglib prefix=sql uri=httpjavasuncomjstlsql gtlt include file=RemoveCachejsp gtciDOCTYPE HTML PUBLIC ldquo-W3CDTD HTML 401 TransitionalENgtlthtmlgtltheadxtitlegtUpdate Location lnformationlttitlegtcmeta http-equiv=Content-Type content=texthtml charset=iso-8859-1 gtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtclink href=WebOutlookcss rel=styiesheet type=textcssgtcheadgtcbody text=000000 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0]reset()gtch2 align=center class=WebOutlookgtOnline Multimedia Communication Systemch2gtccset var=h value=omcsgtccset var=u value=raygtccset var=l value=omcsgtccset var=p value=raygtccset var=d value=OMCSgtccset var=file value=FILEgtccset var=location value=LOCATION7gt
csqksetDataSource driver=commysqljdbcDriverurl=jdbcmysql$I$duser=$uamppassword=$pgtcTarget directory is homerayprojectwebappvideoString saveDirectory =homerayprojectwebappvideomaximum 3 files 5M per filesint maxPostSize = 300 1024 1024 int LocationlDQ = 0int i = 0
T Get the values of the parameters from Mainjsp by session 7String userid =String LJD =String Locationjd = 1(session getAttribute(L_IDjequals())sessiongetAttribute(L_ID)toString()String userSession =(sessiongetAttribute(userSession)equals())(String)sessiongetAttribute(userSessionj
try
try if (requestgetParameter(userid)toString()length()gt0)
userid = (String)requestgetParameter(useridj catch (Exception e)if (requestgetAttribute(useridjtoString()length()gt0)
userid = (String)requestgetAttribute(userid)else userid = userSession
if (useridequals(userSession))
93
User current_user = Userfind(userid) userid = current_usergetUserid()LJD = (String) sessiongetAttribute(L_ID)Location nowjocal = LocationfindLocation(LJD)
String LOCATIONID =(((String)sessiongetAttribute(LOCATIONID)toString())length() gt0)(String)sessiongetAttribute(LOCATIONID)toString()
String LADDRESS = (((String)sessiongetAttribute(LADDRESS)toString())length() gt0)(String)sessiongetAttribute(LADDRESS)toString()
String LTELEPHONE =(((String)sessiongetAttribute(LTELEPHONE)toString())length() gt0)(String)sessiongetAttribute(LTELEPHONE)toString()
String DESCRIPTION =(((String)sessiongetAttribute(DESCRIPTION)toString())length() gt0)(String)sessiongetAttribute(DESCRIPTION)toString()
String EFFECTDATE =(((String)sessiongetAttribute(EFFECTDATE)toString())length() gt0)(String)sessiongetAttribute(EFFEOTDATE)toString()
String STATUS = (((String)sessiongetAttribute(STATUS)toString())length() gt0)(String)sessiongetAttribute(STATUS)toString()
String USERID = (((String)sessiongetAttribute(USERID)toString())length() gt0)(String)sessiongetAttribute(USERiD)toString()
int counter = 0 gtcsqkquery var=resultgtSELECT FROM ccout value=$location7gt WHERE USERID =c=current_usergetUserid()gt ORDER BY LOCATIONIDcsqlquerygtctable aiign=center width=400gtctr valign=middiegtctd height=40gtcp align=center class=PageTitlegtUpdate Locationscpgtctdgtctrgtctablegt cp class=displayLocationgtLogin raquo Main raquo Update Location informationcpgt ctable width=94 border=1 height=291 gt
ctrgtcform name=SelectLocation id=SelectLocation action=SelectLocationServletldquo
method=POSTgtctd height=49 colspan=2gt Select the current locations
cinput type=hidden name=userid id=userid value=c=useridraquocSELECT NAME=LJD onChange=SeIectLocationServlet class=linkTextgt
cOPTIONgt-SELECT LOCATION-ccforEach var=row items=$resultrowsBylndexgt
cOPTION value=ccout vaiue=$row[0]gtgtccoutvalue=$row[3]gt
ccforEachgtcbrxinput class=ButtonText type=submit name=Submit1 value=Send
LocationscSELECTgt
ctdgtcformgtctrgt
csqkquery var=resultjilegtSELECT FROM ccout value=$locationldquogt WHERE LOCATIONID = c=LJDgtORDER BY LOCATIONID csqiquerygt
94
lttrgtctd width=59 height=285 align=centergt
cdiv align=centergtLocation lnformationcbrgtcdivgtcform name=UpdateLocation id=UpdateLocation action=Updatel_ocationServlet method=POSTgt
ctable width=80degd border=1 align=center class=linkTextgt ccforEach var=row items=$result_filerowsBylndexgt
ctr onMouseOver=thisstylebackground=CFDEF5lsquo onMouseOut=thisstylebackground=gt
ctdgtLOGATION_IDctdgtctdxinput type=text name=LOCATIONID id=LOCATIONIDrdquo
VALUE =c=LOCATIONIDgt readonlygtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtLOCATION ADDRESSctdgtctdxinput type=text name=LADDRESS id=LADDRESS VALUE
=c=LADDRESSgt maxlength=100xtdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtPHONEctdgtctdxinput type=text name=LTELEPHONE id=LTELEPHONE
VALUE =c=LTELEPHONEgt maxlength=30xtdgtctrgtctr onMouseOver=thisstylebackground=lsquoCFDEF5
onMouseOut=thisstylebackground=gtctdgtDESCRIPTIONctdgtctdxinput type=text name=DESCRIPTION id=DESCRlPTION
VALUE =c=DESCRIPTIONgt maxlength=200gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=thisstylebackground=gtctdgtEFFECT DATEctdgtctdxinput type=text name=EFFECTDATE id=EFFECTDATE
VALUE =c=EFFECTDATEgt maxlength=10gtctdgtctrgtctr onMouseOver=thisstylebackground=CFDEF5
onMouseOut=ldquothisstylebackground=gtctdgtSTATUSctdgtc String now_status - None
if (nowJocalgetStatusOtoStringOequalsCNj) now_status =New Apply
else if (nowJocalgetStatus()toString()equals(W))now_status = Active
else if (nowJocalgetStatus()toString()equals(S))- now_status = Stop
gtctdgtcinput type=text name=STATUS id=STATUS VALUE
=c=now_statusgt readonlygtctdgt
ctrgt
95
ctr onMouseOver=thisstylebackground=CFDEF5 onMouseOut=thisstylebackground=gt
ctdgtUSERIDctdgtctdxinput type=ldquotext name=USERID id=USERID VALUE
=c=USERIDgt readonlygtctdgtctrgt
ccforEachgtctr bgcolor=FF0033xtd height=3 colspan=2gtctdgtctrgt ctr valign=middlextd colspan=2gt
cinput type=submit name=submit2 value=Updateclass=ButtonT extgt
cinput class=ButtonText type=reset value=Resetgt ctdxtrgt
ctablegtcformgt
ctdgtctd width=41ldquo height=285gt
ctable cellpadding=O cellspacing=O border=0 class=OmcsTitle align=center width=95gt
ctrgtctd height=25 width=40 nowrapgtUser IDctdgt ctd x=current_usergetUserid()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtFirst Namectdgt ctd x=current_usergetFirstName()xtdgt
ctrgtctr bgcoIor=E3BEE9xtd height=2 colspan=2xtdxtrgt
ctrgtctd height=25 width=40 nowrapgtLast Namectdgt ctd gtc=current_usergetLastName()gtctdgt
ctrgtctr bgcolor=E3BEE9gtctd height=2 colspan=2gtctdxtrgt
lttrgtctd height=25 width=40 nowrapgtMiddle Namectdgt ctd x=current_usergetMiddleName()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtE-Mailctdgt ctd x=current_usergetEmail()xtdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtAddressctdgt ctd gtc=current_usergetAddress()gtctdgt
ctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2xtdgtctrgt
ctrgtctd height=25 width=40 nowrapgtTelephonectdgt ctd gtc=current_usergetTelephone()gtctdgt
ctrgt
96
ctr bgcolor=E3BEE9xtd height=2ldquo colspan=2gtctdgtctrgtctrgtctd height=25 width=40 nowrapgtGenderctdgt ctd gtc if (current_usergetGender()equals(m))
outprintln(Maie)else outprintln(Female)
gtctdgtctrgtctr bgcolor=E3BEE9xtd height=2 colspan=2gtctdgtctrgt
ctrgtctd height=25 width=40 nowrapgtRolectdgt ctd gtc if (current_usergetRole()equals(Aj)
outprintln(Administrator) else if (current_usergetRole()equals(Uj)
outprintln(Userj else if (current_usergetRole()equals(Nj)
outprintln(New User)else
outprintln(Not a valuable user)gtctdgt
ctrgtctablegtctdgtctrxtd colspan=2 align=centerxa href=Mainjspuserid=c=useridgt
style=text-decorationnonegtMain Functioncagtctdgtctrgt ctablegtc
else sessionsetAttribute(errorThe session is not correct) requestsetAttribute(errorThe session is not correct) responsesendRedirect(OMCSErrorMessagejspj
catch(Exception exc)sessionsetAttribute(errorOut from UpdateLocationResultjsp + Locationjd +
userid + exc)sessionsetAttribute(SourcePageUpdateLocationjspjresponsesendRedirect(OMCSErrorMessagejspj
gtcbodygtchtmlgt
97
Filename logoutjsplt page import=project gtlt page import=javasql gtlt page import=javautiljavaio gtlt page import=project gtlt page contentType=texthtml gtlt include file=RemoveCachejsp gtlthtmlgtltheadxtitlegtLogout Pagelttitlegtclink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgtcheadgtcjspinclude page=adminheadinc gtcjspinclude page=hiddenerrorjsp gt
cbody text=03ff00 link=0000FF onLoad=if (Navigator == navigatorappName) documenttorms[0] reset() gtch2 align=center class=ldquoWebOutlookgtOnline Multimedia Communication Systemch2gt
c clean the values of the parameters of session try sessionsetAttribute(LogOKNojsessionsetAttribute(userNojsessionsetAttribute(useridNoj
sessioninvalidate() sessionisNew()session removeAttributefLogOkj session removeAttribute(userj session removeAttribute(userid)gtsession(userid) = c=sessiongetAttribute(userid)gt c
requestsetAttribute(errorThe session is not correct) responsesendRedirectfloginjspj
catch(Exception exc)responsesendRedirectfloginjspj
gtcbodygtchtmlgtFilename OMCSErrorMessagejspc page contentType=texthtml charset=iso-8859-1 language=java import=javasql gtc page import=project gtc page import=javautiljavaio gtc include file=RemoveCachejspldquo gtchtmlgtcheadgtdink href=WebOutlookcss rel=stylesheet type=textcssgtcMETA HTTP-EQUIV=CACHE-CONTROL CONTENT=NO-CACHEgt
98
ctitlegtError Messagelttitlegtltheadgt
cbody onl_oad=if (Navigator == navigatorappName) documentforms[0]reset()gt ch2 class=WebOutlook align=centergtOnline Multimedia Communication Systemch2gt
ctable width=800 align=center bgcolor=66CCCCgt ctr align=centergtctd colspan=2gt Error Messagesctdgtctrgt ctr align=centergtctd
width=30gterrorctdxtdx=sessiongetAttribute(error)xtdxtrgt ctr align=centergtctd width=30gtSource
Pagectdgtctdgtc=sessiongetAttribute(SourcePage)gtctdgtctrgtctrxtd colspan=2 align=centerxa href=loginjspgtLogin Pagecagtctdxtrgt ctablegt
cbodygtchtmlgtc sessionremoveAttributeCerror) gtc sessionremoveAttribute(SourcePagej gt
99
Filename LoginServletjava package project
import javaxservletimport javaxservlethttpimport javaiolOException
public class LoginServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher MainPage
public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if (MainPage == null)
throw new ServletException(ConstantsMainPagePath + not found)
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException lOExceptionString userid = requestgetParameter(UseridjString password = requestgetParameter(p_word)
boolean errorFlag = false if (userid == null) requestsetAttributeferror User ID is a required)
errorFlag = true
User user = null try
user = Userfind(userid) if (user == null)
requestsetAttribute(error User ID doesnt exist) errorFlag = true
if ( usergetPassword() == null)
requestsetAttribute(error Password is Empty) errorFlag = true
if (usergetPassword()equals(password))
requestsetAttribute(error Password incorrect) errorFlag = true
catch (Exception e)
requestsetAttribute(error Cant find the User) errorFlag = true
100
checking)
if ( errorFlag ) errorFlag = falseloginPageforward(request response)
else HttpSession session = requestgetSession() sessionsetAttribute(userSession userid) sessionsetAttribute(errorAfter session) requestsetAttribute(errorSet Request error after success
requestsetAttribute(useridldquo userid) MainPageforward(request response)
101
Filename RegisterServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIang Integer
public class RegisterServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher registerResultPage
RequestDispatcher registerPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)registerResultPage= contextgetRequestDispatcher(ConstantsregisterResultPagePath) if (registerResultPage == null)
throw new ServletException(ConstantsregisterResultPagePath + not found)
registerPage = contextgetRequestDispatcher(ConstantsregisterPagePath) if (registerPage == null)
throw new ServletException(ConstantsregisterPagePath + notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
tryString requestedResource = ray_projectregisterjsp boolean errorFlag = falseString error =HttpSession session = requestgetSession()String fname =
(requestgetParameter(fname)=null)requestgetParameter(fnamejString Iname =
(requestgetParameter(lname)=null)requestgetParameter(lname)String mname =
(requestgetParameter(mname)=null)requestgetParameter(mname)String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)String password =
(requestgetParameter(password)=null)requestgetParameter(password)
102
String password_c =(requestgetParameter(password_c)=null)requestgetParameter(password_c)
String address =(requestgetParameter(address)=nuli)requestgetParameter(address)
String phone =(requestgetParameter(phonej=nuII)requestgetParameter(phone)
String gender =(requestgetParameter(gender)=null)requestgetParameter(gender)
String email = (requestgetParameter(email)=nun)requestgetParameter(emailjif (fnameequals())
error += First Name is required errorFlag = true
if (lnameequals(j )
error += Last Name is required errorFlag = true
if ( passwordequals(j )
error += Password is required errorFlag = true
if ( password_cequals(j )
error += Password confirm is required errorFlag = true
if (password_cequals(password))
error += Password is not match errorFlag = true
if ( addressequals(j )
error += Address Name is required errorFlag = true
if (genderequals(j )
error += Gender is required errorFlag = true
if ( emailequals(j )
error += Email is required errorFlag = true
if ( errorFlag == true)
requestsetAttribute(errorerror)sessionsetAttribute(lname Iname) sessionsetAttribute(fname fname) sessionsetAttribute(mname mname) sessionsetAttribute(userid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) session setAttributefsuccess failj
103
registerResultPageforward(request response)responsesendRedirect(registerPage)
return User tempUser = Userfind(userid)
requestremoveAttribute(errorjsessionsetAttribute(lname Iname) sessionsetAttributeffname fname) sessionsetAttributefmname mname) sessionsetAttributefuserid userid) sessionsetAttributefpassword password) sessionsetAttributefaddress1 address) sessionsetAttributefphone phone) sessionsetAttributefgender gender) sessionsetAttributefemail email) sessionsetAttribute(successOK) if (tempUser = null)
requestsetAttribute(error User ID exist) registerPageforward(request response) return
else User new_user = nullnew_user = tempUserinsertJnfo(fnamelname mname
useridpassword address phone gender emailU)if ( new_user == null)
requestsetAttribute(error Insert Error1)registerPageforward(request response) return
catch (Exception e) throw new ServietException(insert error in the Exception +
etoStringO)HttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource) if (requestedResource == null)
requestedResource = requestgetContextPath() + ConstantsregisterResultPagePath else
sessionremoveAttribute(requestedResourcejresponsesendRedirect(requestedResource)
return
104
Filename Constantsjavapackage projectimport javautilVectorpublic class Constants
public static final String summaryPagePath = summaryjsp public static final String errorPagePath = OMCSErrorMessagejsp public static final String loginPagePath = loginjsppublic static final String MainPagePath = Mainjsppublic static final String registerPagePath = registerjsppublic static final String registerResuItPagePath = registerResuItl jsppublic static final String UpdatePersonalPagePath = UpdatePersonaljsppublic static final String RemoveUserPagePath = ldquoRemoveUserjsppublic static final String UploadFilePagePath = UploadFilejsppublic static final String RequestLocationPagePath = RequestLocationjsppublic static final String FileManagementPagePath = FileManagementjsppublic static final String SetupLocationPagePath = SetupLocationsjsppublic static final String UpdateLocationPagePath = UpdateLocationjsppublic static final String UpdateLocationResultPagePath = UpdateLocationResultjsp
public static final String jndiContainerContext = javacompenvpublic static final String jndiDatabaseName = databasepublic static final String fileTableName = FILEpublic static final String userfiieTableName = USERFILEpublic static final String userTableName = USERpublic static final String locationTableName = LOCATION
105
Filename Userjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtable
public class User
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource1)
catch (Exception e) throw new RuntimeException(e)
static private String userid static private String firstname static private String lastname static private String middlename static private String email static private String password static private String address static private String telephone static private String gender static private String role
public User ( String userid String firstname String lastnameString middlename String email String passwordString address String telephone String genderString role)
thisuserid = userid thisfirstname = firstname thislastname = lastname thismiddlename = middlename thisemail = email thispassword = password thisaddress = address thistelephone ^telephone thisgender = gender thisrole = role
106
public void setUserid(String userid)thisuserid = userid public void setFirstName(String firstname)thisfirstname = firstname public void setl_astName(String lastname)thislastname = lastname public void setMiddleName(String middlename)thismiddlename = middlename public void setEmail(String email)thisemail = emailpublic void setPassword(String password)thispassword = password public void setAddress(String address)thisaddress = address public void setTelephone(String phone)thistelephone = phone public void setGender(String gender)thisgender = gender public void setRoie(String role)thisrole = role
public String getUserid() public String getFirstName() public String getLastName() public String getMiddleName() public String getEmail() public String getPassword() public String getAddress() public String getTelephone() public String getGender() public String getRoieQ
return thisuserid return thisfirstname
return thislastname return thismiddlename return thisemail
return thispassword return thisaddress
return thistelephone return thisgender
return thisrole check user id exist or not 7public static boolean id_exist(String userid) throws Exception
User user = nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = nulltry
connection = dsgetConnection() statement = connection createStatement()String s = ldquoselect userid from USER where userid =
ps = connectionprepareStatement(s) pssetString(1 userid) int result = psexecuteUpdate() rs = statementexecuteQuery(s) if (result == 0) return false finally
rsclose()statement close()connectionclose()
107
return true end of id_exist
inser new user 7public static User insert_info(String firstname String lastname String middle_name String userid String password String address String phone String gender String email String role) throws SQLException
if ( userid == null) return nullif ( password == null) return nullif (firstname == null) return nullif (lastname == null) return nullif ( email == null) return nullif (role == null) return nullif ( middle_name == null) middle_name =
User user = null boolean works = falseConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null try
connection = dsgetConnection() statement = connectioncreateStatement()
String s = insert into USER (userid firstname lastname middlename email password address telephone gender role) values ()
ps = connectionprepareStatement(s) pssetString(1 userid) pssetString(2 firstname) pssetString(3 lastname) pssetString(4 middle_name)
pssetString(5 email) pssetString(6 password)
pssetString(7 address) pssetString(8 phone)
pssetString(9 gender)pssetString(10 role)int result = psexecuteUpdate()rs = statementexecuteQueryCselect from USER)if (result == 0) return null
finally if ( ps = null) psclose() if (rs = null) rsclose() if (statement = null) statementclose() if ( connection = null) connectionclose()
return new User (userid firstname lastname middlename email password address
phone gender role) end of insert
updater user info - need to change Sep-7-04
108
public static User update_info( String firstname String lastname String middlename String userid String password String address String phone String gender String email) throws SQLException
if ( password == null) return null
if ( userid == null) return nullif (firstname == null) return null if (lastname == null) return null
if ( email == null) return nullConnection connection = nullStatement statement = nullResultSet rs = null
PreparedStatement ps = null int result = 0
tryconnection - dsgetConnection() statement = connectioncreateStatement()
String s = UPDATE USER SET firstname= Iastname= middlename^ password= address= telephone= gender= emaii= role= WHERE userid =
ps = connection prepareStatement(s) pssetString(1 firstname) pssetString(2 lastname) pssetString(3 middlename) pssetString(4 password) pssetString(5 address) pssetString(6 phone) pssetString(7 gender) pssetString(8 email) pssetString(9 role) pssetString(1O userid) result = psexecuteUpdate()
finally if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null else
return new User (userid firstname lastname middlename email password address phone gender role)
end of update_person
remove a record from USER where userid = userid public static String RemoveUser(String userid) throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0 String admin =
109
tryconnection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT USERID FROM USER WHERE ROLE = ps = connectionprepareStatement(s) pssetString(1 A)rs = psexecuteGuery()if (IrsfirstQ) return flaseelse admin = rsgetString(userid)
catch (Exception co) if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET userid = + admin + Where
userid = ps = connectionprepareStatement(s) pssetString(1 userid) result = psexecuteUpdate() psclose()String first = UPDATE FILE SET userid = + admin + Where
userid = ps = connectionprepareStatement(first) pssetString(1 userid) result = psexecuteUpdate() psciose()String second = DELETE FROM USER WHERE USERID = ps = connectionprepareStatement(second) pssetString(1 userid)result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
String reString = (result==O)truefalse return reString
fit
returns null if userid doesnt exist 7public static User find(String userid) throws Exception User user = null
Connection connection = null
110
Statement statement = nullResultSet rs = nullPreparedStatement ps = null int result = 0
try connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT FROM USER WHERE USERID =
ps = connectionprepareStatement(s) pssetString(1 userid) rs = psexecuteQuery()
if (rsfirst()) return nullString firstname = rsgetString(firstnamelsquojString lastname - rsgetString(lastnamejString middlename = rsgetString(middlename) String email = rsgetString(emailj
String password = rsgetStringfpasswordjString address = rsgetString(addressjString telephone = rsgetString(telephonejString gender = rsgetStringCgenderjString role = rsgetString(roIej
user = new User(userid firstname lastname middlename emailpassword address telephone gender role)
finally
psclose() rsclose() statementclose()
connectionclose()return user
end of find(userid)
111
Filename Filesjavapackage project
import javasqlimport javaioFileimport javaiolOExceptionimport javaioInputStreamimport javaioOutputStreamimport javaioBufferedlnputStreamimport javaioBufferedOutputStreamimport javaxnamingimport javaxservletimport javaxservlethttpimport javaxsqlDataSourceimport javaxnamingNamingException
public class Files
static private DataSource ds
static
tryInitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String filename private String filepath private String locationlD private String size private String created_date private String last_access_date private String created_time private String last_access private String userid
public Fiies(String filenameString filepath String locationlD String size String created_date String last_access_date String created_time String last_access String userid)
thisfilename = filename thisfilepath = filepath thislocationlD = locationlD thissize = sizethiscreated_date = created_date thislast_access_date = last_access_date thiscreated_time = created_time thislast_access = last_access
112
thisuserid = userid
public String getFilename() return filenamepublic String getLocation() return locationlDpublic String getSize() return sizepublic String getCreated_date() return created_datepublic String getLast_access_date() return last_access_datepublic String getCreated_time() return created_timepublic String getLast_access() return last_accesspublic String getOwner() return userid
public void setSize(String VideoSize) thissize = VideoSize public void setFilename(String name) thisfilename = name public void setLocation(String locationlD) thislocationlD = locationlD
throws AuthenticationException if user credentials are not valid 7public static Files findByUserid(String userid) throws SQLException
Connection connection = nullPreparedStatement ps = nullResuitSet rs = null try
connection = dsgetConnection()String sql = select from + ConstantsfileTableName + where USERID = ps = connectionprepareStatement(sql) pssetString(1 userid)rs = psexecuteOuery() if (rsfirst())
User has filefilesString filename = rsgetString(ldquofilenamejString locationlD = rsgetString(locationlDjString filepath = rsgetString(filepathj
String userlD = rsgetStringfUSERID)String VideoSize = rsgetString(Sizej
String created_date = rsgetDate(created_date)toString() String last_access_date =
rsgetDate(last_access_date)toString()String created_time = rsgetTime(created_time)toString() String last_access = rsgetTime(Iast_access)toString()
return new Files(filename filepath locationlD userlD VideoSize created_date last_access_date created_time last_access)
finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
User not found -- create the user- return null should not happen becauseof the userid
= owner
113
return null create(userid)
public static Files StoreFilelnfo(String filename String filepath String iocationlD String sizeString created_dateString last_access_date String created_time String Iast_access String userlD)
throws SQLException
if ( userlD == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()String sql = insert into + ConstantsfileTableName + (FILENAME FILEPATH
LOCATIONID SIZE CREATEDDATE + LASTACCESSDATE CREATEDTIME LAST ACCESSTIME USERID)
valuesps = connectionprepareStatement(sql) pssetString(1 filename)
pssetString(2 filepath) pssetString(3 IocationlD) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 userlD)
int result = psexecuteUpdate() psclose()sql = ldquoselect from + ConstantsfileTableName + where FILENAME = ldquo ps = connectionprepareStatement(sql) pssetString(1 filename)rs - psexecuteQuery() rsnext()return new Files(filename filepath IocationlD size created_date last_access_date
created_time last_access userlD) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connection = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7public static Files create(String filename String filepath String location String owner String
size String created_date String last_access_date String created_time String last_access)throws SQLException
114
if (owner == null) return nullFiles new_file = nullConnection connection = nullPreparedStatement ps = nullResultSet rs = null try
connection = dsgetConnection()
Create new userString sql = insert into +
ConstantsfileTableName + (FILENAME FILEPATH LOCATIOINID SIZE CREATEDDATEldquo+
LASTACCESSDATECREATEDTIME LASTACCESSTIME USERID) values ()
ps = connectionprepareStatement(sql) pssetString(1 filename)pssetString(2 filepath)
pssetString(3 location) pssetString(4 size) pssetString(5 created_date) pssetString(6 last_access_date) pssetString(7 created_time) pssetString(8 last_access) pssetString(9 owner)
int result = psexecuteUpdate() psclose()
Get the auto-generated idsql = select from + ConstantsfileTableName + where FILENAME = ps = connectionprepareStatement(sql) pssetString(1 filename)rs = psexecuteQuery() rsnext()return new Files(filename filepath location size created_date iast_access_date
created_time last_access owner) finally
if (rs = null) rsclose()if (ps = null) psclose()if (connectidegn = null) connectionclose()
If another thread tries to create this user then an exception is thrown since userid is unique in users table Because this event is rare and has no serious consequencies we dont handle this case7
public static String deleteDBFiie(String filename String path) throws SQLException
Connection connection = nullStatement statement - null
115
PreparedStatement ps = null int result = 0 String parent = httpsomcsiascsusbedu8443ray_project boolean retval = false long fiielength = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String sql = DELETE FROM + ConstantsfileTableName + where
filename = ps = connectionprepareStatement(sql) pssetString(1 filename) result = psexecuteUpdate() finally if (ps = null) psclose()if (statement = null) statementclose()if (connection = null) connectionclose()
bull String reString = (result==O)truefalse return reString
Delete the file from Serverpublic static String deleteHDFile(String filename String path) throws SQLException
Process p = nullRuntime r = nullString filehome = homerayprojectwebapp + path try
r = RuntimegetRuntimeOString[] remove = binrm -f filehome p = rexec(remove)int status = pwaitFor() if( status = 0 )
return false
return true catch ( Exception e)
return false
116
Filename Locationjavapackage project
import javaiolOExceptionimport javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javautilVector
public class Location
static private DataSource ds static
try
InitialContext ic = new lnitialContext()Context tomcatContext = (Context) iclookup(ConstantsjndiContainerContext) ds = (DataSource) tomcatContextlookup(ConstantsjndiDatabaseName) if (ds == null) throw new RuntimeException(no DataSource)
catch (Exception e) throw new RuntimeException(e)
private String locationjd private String address private String telephone private String description private String effectdate private String status private String userid
public Location ( String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid)
this locationjd = Locationjd thisaddress = Address thistelephone = Telephone thisdescription = Description thiseffectdate = Effectdate thisstatus = Status thisuserid = Userid
public String getLocationJd() public String getAddress() public String getTelephone() public String getDescription() public String getEffectdate()
return locationjd return address
return telephone return description return effectdate
public String getStatus() return status public String getUserid() return userid
returns null if owner doesnt exit 7
117
public static Location findLocation(String locationlD) throws Exception
Location place = nullConnection connection = nullStatement statement = nullVector locations = new Vector()ResultSet rs = null try
connection = dsgetConnection() statement = connectioncreateStatement()String s = select from LOCATION where LOCATIONID = +
locationlD +int i = 0rs = statementexecuteQuery(s) while (rsnext())String locationjd = rsgetString(LOCATIONIDldquo)String address = rsgetString(LADDRESS)String phone = rsgetStringCLTELEPHONE)String description = rsgetString(DESCRIPTION)String effectdate = rsgetString(EFFECTDATE)String status = rsgetString(STATUS)String userid = rsgetString(USERID)place = new Location(location_id addressphone
descriptioneffectdatestatus userid)
finally
rsclose() statement close() connectionclose()
return place
public static String NewLocationlD() throws Exception
Connection connection = nullStatement statement = nullResultSet rs = nullString newlD = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = SELECT LOCATIONID FROM LOCATION ORDER BY
LOCATIONIDint i = 0String step =rs = statementexecuteOuery(s) while (rsnext())
String locationjd = rsgetString(LOCATIONID) rsRecordCount
118
i = Integerparselnt(locationjd) if (Integerparselnt(newlD) lt= i)
newlD = + (i+1)
for (int j = 0 j lt 6-newlDlength() j++ ) step += 0
newlD = step + newlD
finally
rsclose() statementclose() connectionclose()
return newlD
public static Location lnserLocation(String Locationjd String AddressString
Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0 try
connection = dsgetConnection() statement = connectioncreateStatement()String s = insert into + ConstantslocationTableName +
(LOCATIONID LADDRESS LTELEPHONE DESCRIPTION + EFFECTDATE STATUS USERID) values
(999999 9)- bull J
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) result = psexecuteUpdate() psclose()
finally
if ( ps = null) psclose() if (rs = null) rsclose() if ( statement = null) statementclose() if (connection = null) connectionclose()
if (result == 0) return null
else return new Location(LocationJd Address Telephone Description
Effectdate Status Userid)
119
public static Location UpdateLocation(String Locationjd String AddressString Telephone String Description String Effectdate String Status String Userid) throws Exception
Connection connection = nullStatement statement = nullPreparedStatement ps = nullResultSet rs = null int result = 0try
connection = dsgetConnection() statement = connectioncreateStatement()String s = UPDATE LOCATION SET LOCATIONID = LADDRESS
= LTELEPHONE = DESCRIPTION = EFFECTDATE = STATUS = USERID = WHERE LOCATIONID =
ps = connectionprepareStatement(s) pssetString(1 Locationjd)
pssetString(2 Address) pssetString(3 Telephone) pssetString(4 Description) pssetString(5 Effectdate) pssetString(6 Status) pssetString(7 Userid) pssetString(8 Locationjd) result = psexecuteUpdate()
finaliyf
if ( ps = null) pscloseO if (rs = null) rsclose() if ( statement = null) statementclose() if ( connection = null) connectionclose()
if (result == 0) return null
else return new Location (Locationjd Address Telephone Description
Effectdate Status Userid)
120
Filename update_personjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxserviethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class update_person extends HttpServlet
RequestDispatcher loginPageRequestDispatcher update_personPageRequestDispatcher MainPagepublic void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)update_personPage= contextgetRequestDispatcher(ConstantsUpdatePersonalPagePath) if ( update_personPage == null)
throw new ServletException(ConstantsUpdatePersonalPagePath + is not found)MainPage = contextgetRequestDispatcher(ConstantsMainPagePath) if ( MainPage == null)
throw new ServletException(ConstantsMainPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
boolean checkid = false String first_name = requestgetParameter(first_namejString last_name = requestgetParameter(last_namejString middle_name = requestgetParameter(middle_namejString userid = requestgetParameter(useridjString password - requestgetParameter(passwordjString password_c = requestgetParameter(password_cjString address = requestgetParameter(addressjString phone = requestgetParameter(telephonejString gender = requestgetParameter(genderjString email = requestgetParameter(emailjString first_name_Iength = nullUser temp = null
boolean error = falseString errorstring =
if (first_nameequals(j ) errorstring += First Name is required
121
error = trueif (last_nameequals())
errorstring += Last Name is required error = true
if ( passwordequals()) errorstring += Password is required error = true
if ( password_cequals(j ) errorstring += Confirm Password is required error = true
if ( addressequals()) errorstring += Address is required error = true
if (genderequals(j ) errorstring += gender is required error = true
if ( emailequals()) errorString += E-Mail is required
error = true
if (error) error = falserequestsetAttribute(error errorString)
update_personPageforward(requestresponse)else
tryUser new_user - nullnew_user = tempupdate_info(first_namelast_name middle_name
useridpassword address phone gender email)HttpSession session = requestgetSession()
if ( new_user == null) sessionsetAttribute(error Update Error return new_user == null)
sessionsetAttribute(first_name first_name)
update_personPageforward(request response) catch (Exception e)
throw new ServletException(update error + etoStringO)
122
Filename UploadFileSelectLocalServletjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UploadFileSelectLocalServlet extends HttpServlet
FtequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFilePage = contextgetRequestDispatcher(ConstantsUploadFilePagePath)
if ( UploadFilePage == null)throw new ServletException(ConstantsUploadFilePagePath + is not
found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is notfound)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSelectLocationServletjava)String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(ldquoSourcePage SelectLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUploadFilePagePath)) sessionremoveAttribute(requestedResourcej
requestsetAttribute(userid userid) UploadFiIePageforward(request response)
else ErrorPageforward(request response)
123
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsUploadFilePagePath)) session removeAttribute(requestedResource)
requestsetAttribute(userid userid) UploadFilePageforward(request response)
else requestsetAttribute(error userid) ErrorPageforward(request response)
124
Filename UploadFileServletjavapackage project
import javaxservletimport javaxservlethttpimport javaxservletServletlnputStreamimport javaiolOExceptionimport javaioInputStreamimport javatextSimpleDateFormatimport javautilDateimport javautilStringTokenizerimport javautilListimport javautilIteratorimport javaioFileimport javaIangStringimport javaIangObjectimport javaIangLongimport javasqlSQLExceptionimport javasqlTimeimport orgapachecommonsfileuploadFileltemimport orgapachecommonsfileuploadDiskFileUploadimport orgapachecommonsfileupIoadFileUploadimport orgapachecommonsfileuploadFileUploadBase
public class UploadFileServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UploadFilePageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UploadFiIePage= contextgetRequestDispatcher(ConstantsUploadFilePagePath) if ( UploadFilePage == null)
throw new ServletException(ConstantsUploadFilePagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)String repositoryPath = homerayprojectwebappvideoldquoString fSize = nullHttpSession session = requestgetSession()String requestedResource = (String)
sessiongetAttribute(requestedResource)String LJD =String userid =
125
try LJD - (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePageUploadFiIeServletjava) ErrorPageforward(requestresponse)
try
User current_user = Userfind(userid)String the_userid = current_usergetUserid()
Date now = new Date()String ts = nowtoString() And the default time and date-time DateFormatsltbrgt SimpieDateFormat formatterFile = new SimpleDateFormat
(yyyy_MMM_dd_H_mm)SimpleDateFormat formatterDate = new SimpleDateFormat (yyyy
mm-ddjSimpleDateFormat formatterTime = new SimpleDateFormat
(HHMMss)Date currentTime_1 - new Date()String datestring = formatterFileformat(currentTime_1)String createdDateString = formatterDateformat(currentTimejl) String createdTimeString = formatterTimeformat(currentTime_1)
sessionsetAttribute(now2 dateString)String filenamejime = dateString
sessionsetAttribute(now4 dateString)if ( LJD == null || LJDequals()) LJD = LJsO else
sessionsetAttribute(LJDLJD) sessionsetAttributefuseridthe_userid)
DiskFileUpload fu = new DiskFileUpIoad()List fileltems = null int maxKilobytes = 50 1024 fusetSizeMax(maxKilobytes 1024) try
fileltems = fuparseRequest(request)Iterator itr = fileltemsiterator)
while(itrhasNext()) Fileltem fi = (Fileltem)itrnext()
Check if not form field so as to only handle the file inputs else condition handles the submit button input
if(fiisFormField()) String fname = figetName() sessionsetAttributeffn fname) long k = figetSize() fSize = LongtoString(k) sessionsetAttributeffSize fSize)
126
StringTokenizer tokenizer - newStringTokenizer(figetName() ldquo)
int amount = tokenizercountTokens()for (int i = 0 i lt amount -1 i++) tokenizernextToken()
String currentFile = tokenizernextToken() int indexK = currentFilelastlndexOf() int currentFileJength = currentFileIength() String subfilename =
currentFiIesubstring(indexK currentFileJength)filename Jime = dateString + LJD +
subfilenameFile fNew= new File(repositoryPath filenamejime)
sessionsetAttribute(fPathfNewgetAbsolutePath())String ft=+ fNewlastModified() sessionsetAttribute(ft ft)
fiwrite(fNew)else
requestsetAttribute(ldquoerror isFormField is wrong) requestsetAttribute(SourcePage
UploadFileServletjavaj store Filelnfo to DB String path = video+ filenamejime sessionsetAttribute(filenameJime filenamejime) sessionsetAttribute(the_userid the_userid)
Files UploadFile = new Files(filenamejime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeStringthe_userid)
UploadFile = UploadFileStoreFilelnfo(filenameJime path LJD fSizecreatedDateString createdDateStringcreatedTimeStringcreatedTimeString the_userid)
sessionsetAttribute(userid userid)sessionsetAttribute(userid the_userid) new sessionsetAttributefLJD L_ID) requestsetAttribute(userid userid) UploadFilePageforward(requestresponse)
catch(Exception pr)sessionsetAttribute(error Cant get fileltems+pr)
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else session removeAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + pr)ErrorPageforward(request response)
127
catch (Exception e)sessionsetAttribute(ldquoerror The iterator error+ L_ID + userid + e) sessionsetAttributefSourcePage UploadFileServletjava) ErrorPageforward(request response)
128
Filename SetupLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class SetupLocationsSelectLocalServIet extends HttpServlet
RequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()Setu p Location Page=
contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + isnot found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServietRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMuitipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageSetupLocationsSelectLocalServietjava) String requestedResource = (String)
sessiongetAttribute(requestedResourcejString userid = (String) sessiongetAttribute(useridj try
String LJD = (String) requestgetParameter(L_IDj sessionsetAttribute(L_IDL_ID) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error L_ID parameter error+ e ) sessionsetAttribute(SourcePage SelectLocationServietjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsSetupLocationPagePath)) sessionremoveAttribute(requestedResourcej
SetupLocationPageforward(request response) else
ErrorPageforward(request response)
129
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else if (requestedResourceequals(ConstantsSetupLocationPagePath))
session removeAttributefrequestedResource) requestsetAttribute(ldquouserid userid) Setupl_ocationPageforward(request response)
else requestsetAttribute(error userid)ErrorPageforward(request response)
130
Filename SetupLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class SetupLocationsServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher ErrorPageRequestDispatcher SetupLocationPage public void init() throws ServletException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)SetupLocationPage= contextgetRequestDispatcher(ConstantsSetupLocationPagePath) if ( SetupLocationPage == null)
throw new ServletException(ConstantsSetupLocationPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == nuli)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(L_IDj userid = (String)sessiongetAttribute(useridj
catch (Exception e) sessionsetAttributeferrorCant get userid and LJD) sessionsetAttribute(SourcePageSetupLocationsServletjava) ErrorPageforward(requestresponse)
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESS)toString()equals()requestgetParameter(LADDRESSj
131
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals(jrequestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equaIs()requestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals(jrequestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()ldquorequestgetParameter(USERIDj
String error =boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j)
error += USERID is required errorFlag = true
try
if (errorFIag)requestsetAttribute(errorerror)ErrorPageforward(requestresponse)
Location temp = null
sessionsetAttributefLOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(ldquoDESCRIPTION DESCRIPTION)
132
sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttributefSTATUS STATUS) sessionsetAttributefUSERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
sessionsetAttribute(LJD LJD) requestsetAttribute(useriduserid) SetupLocationPageforward(requestresponse)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttribute(SourcePage UpdateLocationServletjavaj
if (requestedResource == null) requestedResource = requestgetContextPath() +
ConstantserrorPagePath else
sessionremoveAttribute(requestedResource)
sessionsetAttribute(error Servlet wrong + e) ErrorPageforward(requestresponse)
133
Filename RemoveUserServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RemovellserPageRequestDispatcher update_resultPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemovellserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemovellserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString() length ()gt0)requestgetParameter(deleteidjtoStr ing()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()
User new_user = null try
HttpSession session = requestgetSession() if ( deleteidIength() gt 0 )
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (Isuccessequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success) RemoveUserPageforward(request response)
catch (Exception e)
134
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
135
Filename FileManagementServIetjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RemoveUserServlet extends HttpServlet
RequestDispatcher IoginPageRequestDispatcher RemoveUserPageRequestDispatcher update_resultPage public void init() throws ServietException
ServletContext context = getServletContext()IoginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (IoginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RemoveUserPage = contextgetRequestDispatcher(ConstantsRemoveUserPagePath) if ( RemoveUserPage == null)
throw new ServletException(ConstantsRemoveUserPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServietException lOException
String success = stupidString deleteid =
(requestgetParameter(deleteid)toString()length()gt0)requestgetParameter(deieteid)toString()
String userid =(requestgetParameter(userid)toString() length ()gt0)requestgetParameter(userid)toString ()rdquo
User new_user = null try
HttpSession session = requestgetSession() if (deleteidIength() gt 0)
success = new_userRemoveUser(deleteid) success = deleteid
else success = deleteid
if (successequals(deleteid))
requestsetAttribute(error Update Error return RemoveUser = false + success ) RemoveUserPageforward(request response)
catch (Exception e)
136
throw new ServletException(Remove User error + success + deleteid + removed fail in RemoveUserjspn + etoStringO)
HttpSession session = requestgetSession()
requestsetAttribute(useriduserid)RemoveUserPageforward(request response)
137
Filename UpdateLocationSelectLocalServietjavapackage project
import javaxservletimport javaxservlethttpimport javaiolOExceptionimport javaioInputStream
public class UpdateLocationSelectLocalServlet extends HttpServlet
RequestDispatcher UpdateLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()UpdateLocationPage -
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath)
if ( ErrorPage == null)throw new ServletException(ConstantserrorPagePath + is not
found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
Check that we have a file upload requestboolean isMultipart = FileUploadisMultipartContent(request)HttpSession session = requestgetSession()sessionsetAttribute(SourcePageUpdateLocationSeIectLocalServletjavaj String requestedResource = (String)
sessiongetAttributefrequestedResource)String userid =
(requestgetParameter(useridjtoString() length ()gt0)requestgetParameter(userid)toString
tryString LJD = (String) requestgetParameter(LJDj sessionsetAttribute(LJDLJD) sessionsetAttribute(useriduserid)
catch (Exception e)
sessionsetAttribute(error LJD parameter error+ e) sessionsetAttribute(SourcePage SelectLocationServletjavaj
ErrorPageforward(request response)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
else if (requestedResourceequals(ConstantsUpdateLocationPagePath))
138
sessionremoveAttribute(requestedResourcej requestsetAttribute(userid userid) Updatel_ocationPageforward(request response)
else sessionsetAttribute(error userid) ErrorPageforward(request response)
139
Filename UpdateLocationServletjavapackage project
import javasqlimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javaIangInteger
public class UpdateLocationServIet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher UpdateLocationPageRequestDispatcher UpdateLocationResultPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath) if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)U pdateLocation Page=
contextgetRequestDispatcher(ConstantsUpdateLocationPagePath) if ( UpdateLocationPage == null)
throw new ServletException(ConstantsUpdateLocationPagePath + is not found)UpdateLocationResultPage=
contextgetRequestDispatcher(ConstantsUpdateLocationResultPagePath) if ( UpdateLocationResultPage == null)
throw new ServletException(ConstantsUpdateLocationResuitPagePath + is not found)ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession()String LJD =String userid = try
LJD = (String) sessiongetAttribute(LJD) userid = (String)sessiongetAttribute(userid)
catch (Exception e) sessionsetAttribute(errorCant get userid and LJD) sessionsetAttribute(SourcePage7SetupLocationsServletjava) ErrorPageforward(requestresponse)
140
String LOCATIONID =
requestgetParameter(LOCATIONID)toString()equals()requestgetParameter(LOCATIONIDj
String LADDRESS =requestgetParameter(LADDRESSjtoString()equals()requestgetParameter(LADDRESSj
String LTELEPHONE =requestgetParameter(LTELEPHONE)toString()equals()requestgetParameter(LTELEPHONE)
String DESCRIPTION =requestgetParameter(DESCRIPTION)toString()equals(ljrequestgetParameter(DESCRIPTIONj
String EFFECTDATE =requestgetParameter(EFFECTDATE)toString()equals()requestgetParameter(EFFECTDATEj
String STATUS =requestgetParameter(STATUS)toString()equals()requestgetParameter(STATUSj
String USERID =requestgetParameter(USERID)toString()equals()requestgetParameter(USERIDj
String error = boolean errorFlag = false if ( LOCATIONIDequalsC))
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECTDATE is required errorFlag = true
if ( STATUSequals(j )
error += STATUS is required errorFlag = true
if ( USERIDequals(j )
error += USERID is required errorFlag = true
try
if (errorFlag)requestsetAttribute(ldquoerrorerror)
141
ErrorPageforward(request response)
Location temp = nullif ( STATUSequals(New Apply)) STATUS = N else if ( STATUSequalsCActivej ) STATUS = W else if ( STATUSequalsfStop) ) STATUS = S
sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttribute(LADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(STATUS STATUS) sessionsetAttribute(USERID USERID)
Location newLocation = nullnewLocation = tempUpdateLocation( LOCATIONID LADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE STATUS USERID) if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null) ErrorPageforward(request response)
return
sessionsetAttribute(L_ID LJD) requestsetAttribute(useriduserid) UpdateLocationResultPageforward(request response)
catch (Exception e) String requestedResource = (String)
sessiongetAttribute(requestedResourcejsessionsetAttribute(error Out from catch+e) sessionsetAttributefSourcePage UpdateLocationServletjavaj if (requestedResource == null)
requestedResource = requestgetContextPath() +Constants UpdateLocation Page Path
else session removeAttribute(requestedResourcej
sessionsetAttribute(error Servlet wrongIn UpdateLocationServletjava +
e)ErrorPageforward(requestresponse)
142
Filename RequestLocationServletjavapackage project
import javasqiimport javaxsqlDataSourceimport javaxnamingimport javaxservletimport javaxservlethttpimport javaiolOExceptionimport javautilHashtableimport javalangInteger
public class RequestLocationServlet extends HttpServlet
RequestDispatcher loginPageRequestDispatcher RequestLocationPageRequestDispatcher ErrorPage public void init() throws ServletException
ServletContext context = getServletContext()loginPage = contextgetRequestDispatcher(ConstantsloginPagePath)if (loginPage == null)
throw new ServletException(ConstantsloginPagePath + not found)RequestLocationPage=
contextgetRequestDispatcher(RequestLocationResultjspjConstantsRequestLocationPagePath)
if ( RequestLocationPage == null)throw new ServletException(ConstantsRequestLocationPagePath + is not found)
ErrorPage= contextgetRequestDispatcher(ConstantserrorPagePath) if ( ErrorPage == null)
throw new ServletException(ConstantserrorPagePath + is not found)
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException lOException
HttpSession session = requestgetSession() boolean errorFlag = false String error =String userid -
(requestgetParameter(userid)=null)requestgetParameter(userid)ldquoString LOCATIONID =
(requestgetParameter(LOCATIONID)=null)requestgetParameter(LOCATIONID) String LADDRESS =
(requestgetParameter(LADDRESS)=nuII)requestgetParameter(LADDRESS)String LTELEPHONE =
(requestgetParameter(LTELEPHONE)=null)requestgetParameter(LTELEPHONE) String DESCRIPTION =
(requestgetParameter(DESCRIPTION)=null)requestgetParameter(DESCRIPTION) String EFFECTDATE =
(requestgetParameter(EFFECTDATE)=null)requestgetParameter(EFFECTDATE)
143
String status =(requestgetParameter(status)=null)requestgetParameter(status)
String requestedResource = (String)session getAttribute(requestedResourcej
Location temp = nullif ( LOCATIONIDequals(ldquo) )
error += Location ID is required errorFlag = true
if ( LADDRESSequals(j )
error += ADDRESS is required errorFlag = true
if ( LTELEPHONEequals(j )
error += TELEPHONE is required errorFlag = true
if ( DESCRIPTIONequals(j )
error += DESCRIPTION is required errorFlag = true
if ( EFFECTDATEequals(j )
error += EFFECT DATE is required errorFlag = true
if ( statusequals(j )
error += Status is required errorFlag = true
try
User nowUser = Userfind(userid) sessionsetAttribute(LOCATIONID LOCATIONID) sessionsetAttributefLADDRESS LADDRESS) sessionsetAttribute(LTELEPHONE LTELEPHONE) sessionsetAttribute(DESCRIPTION DESCRIPTION) sessionsetAttribute(EFFECTDATE EFFECTDATE) sessionsetAttribute(status status)
Location newLocation = nullnewLocation = templnserLocation(LOCATIONIDLADDRESS
LTELEPHONEDESCRIPTION EFFECTDATE status nowUsergetUserid())if ( newLocation == null)
requestsetAttribute(error Update Error return newLocation == null)RequestLocationPageforward(request response)return
catch (Exception e)
sessionsetAttribute(error Insert location error + e) if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantserrorPagePath
144
else session removeAttribute(requestedResource)
ErrorPageforward(requestresponse)if (requestedResource == null)
requestedResource = requestgetContextPath() +ConstantsRequestLocationPagePath
else sessionremoveAttributeCrequestedResource)
requestsetAttribute(userid userid) RequestLocationPageforward(request response)
145
REFERENCES
[1] Jayson Falkner et alBeginning JSP Web Development
First Edition Wrox Press Inc August 2001
[2] Jason Hunter and William Crawford Java Servlet
Programming Second Edition OReilly and Assoicates
2002
[3] PJ Deitel How to Program JAVA Fourth Edition
Deitelamp Associate Inc 2000
[4] PJDeitel How to Program Advanced Java 2 Platform
Deitel amp Associate Inc 2002
[5] Martin Fowler and Kendall Scott UML Distilled- A
brief guide to the standard object modeling
language Second Edition Addison-Wesley July 2001
[6] Ivor Horton Beginning Java 2 JDK 13 EditionWrox
Press Ltd 2000
[7] Ramez Elmasri and Shamkant B Navathe Fundamentals
of Database Systems Third Edition Addison-Wesley
June 2000
[8] Shelly Cashman Woods HTML Complete Concepts and
Techniques second Edition Thomson Course
Technology 2002
[9] Marty Hal-l more Servlets and JavaServer Pages Sun
Microsystems Inc 2002
[10] William B Sanders Javascript Design New riders
2002
146
- Online multimedia communication system
-
- Recommended Citation
-
- dOone
- Figure 6 Login Page - Registered Users
- Locations The browser automatically goes to Request New
- g
- SB
- Figure 9 Main Page (For Users)
- 5210 Request New Locations Page (For Users)
- This function is for Users Any users are able to
- apply newrsquolocations for uploading event files to share
- User can link to this page from Users Main Page
- In this page Location ID is given by system and
- it cannot be changed After User fills out the location
-