You are on page 1of 4

Design and Implementation of Student Attendance

Management System Based on MVC

He Zonggang Zheng Junsheng


Department of Computer Science and Technology Department of Computer Science and Technology
Neusoft Institute of Information Neusoft Institute of Information
Dalian, China Dalian, China
hezonggang@neusoft.edu.cn zhengjunsheng@ neusoft.edu.cn

Abstract—Based on the modern technology of MVC and In order to satisfy those demands and provide relative
J2EE study, Multi-layer structure of J2EE which has been services for both teachers and students, as well as to create a
realized by FreeMarker, WebWork and Spring has been brought high efficient and convenient environmental in campus, a wide
forward, the student attendance management system for all range use of Web system for all college students becomes a
college students which based on MVC has been designed and must.
implemented in this paper. This will use for reference for other
Web Applications system based on J2EE platform. II. THE DESIGN OF SYSTEM WEB APPLICATION
The system is controlled by WebWork while data or status FRAMEWORK
and logic process are enforced by “Action”. Default interceptors
and interceptors were used to decide whether or how to carry out The system uses Multi-layer structure of J2EE which has
the “Action” before “Action” was executed. Interceptors were in been realized by FreeMarker, WebWork and Spring. The
use to complete a series of security, and logs and calibration Framework will realize the MVC pattern of development,
work. To receive a dynamic data from WebWork is by using the allowing low coupling degree of presentation layer, business
technology of FreeMarker in the performance. Many macros logic layer and database server layer, realizing a small amount
were defined to unify the style of system pages, reuse of code of code can be modified to complete changes in system
duplication and improve efficiency. A light weight tool called functionality and database server.
“Spring Ioc Container” is used to manage “Service” in the
business logical layer. And JDBC Template is used for blocking A. Presentation Layer
some complex areas from database and decrease the complexity 1) Page Resources Layer--HTML+CSS+JavaScript
of its process. Three technologies have been used in page resources layer:
The system has been preliminary run in campus by testing and HTML performs structure of document, CSS defines style of
debugging. The result indicates that the direction of this document and JavaScript decides behavior of document.
technology study is correct and the design of this program is HTML is the most common page element markup
essential. language, used for the presentation of document structure. Its
Keywords-Student Attendance Management System; MVC;
shortcoming is to mix data content with its presentation, which
WebWork; FreeMarker; Spring
undoubtedly increase the difficulty and workload of
I. BACKGROUND development. Therefore, the system will minimize the use of
HTML.
As the rapid growth of educational system in China, people CSS is used to control a display style of interface elements
now have more demands on teacher’s knowledge level and the and define the style of the document.
way of teaching method including both hardware and software. When the static pages are identified, their specific behavior
However, the management of teaching method receives more will be achieved by JavaScript. The scripts which are written
demands than others. Gradually the existing student by JavaScript are used to response page events which are used
management system cannot meet the needs of teaching to interact with the user and carry out input data validation.
management, mainly manifested in the following aspects:
2) Page Template Layer-FreeMarker
(1) The various management systems quite is isolated,
The presentation layer is realized by JSP in traditional Web
which cannot guarantee that these teachers who engage in the
development. Although JSP is very powerful, but also often be
teaching work and those teachers who engage in the student
abused and lead to some undesirable consequences, such as
work simultaneously to grasp student’s situation of life and
logic and the presentation will be mixed together, undermining
study and student’s thought tendency.
normal decomposition of the responsibilities of artists and
(2) System has not provided the corresponding service for
programmers, so that it is difficult to read and maintain JSP
the student, truly has not achieved student-centered.
pages. Therefore, the presentation layer is implemented by
(3) Expansibility is poor. With the Institute of expansion
FreeMarker in the system.
and the number of students increasing, the original system
FreeMarker is a template engine: a generic tool to generate
cannot meet the need well.
text output (anything from HTML to autogenerated source
(4) Data security is bad. Data security cannot be guaranteed
code) based on templates. It's a Java package, a class library for
because there is no independent database server.

978-1-4244-4639-1/09/$25.00 ©2009 IEEE


Java programmers. FreeMarker is designed to be practical for First of all, It can manage business logic(Service) of the
the generation of HTML Web pages, particularly by servlet- system.
based applications following the MVC pattern. The idea behind Second, Dependence which is needed by Service can
using the MVC pattern for dynamic Web pages is that you directly be injected into the Service.
separate the designers (HTML authors) from the programmers. Third, it can declare transaction management.
But Java programs prepare the data to be displayed, and Finally, JDBC operation is simply encapsulated by JDBC
FreeMarker just generates textual pages that display the template.
prepared data using templates.
Working mechanism of FreeMarker is shown in Figure 1.
III. THE ANALYSIS OF ATTENDANCE
Template MANAGEMENT SYSTEM

<html> A. function description


… Attendance Management System records and statistics the
Hello student attendance information, and realizes on-line registration
${name}! Output and on-line query. Teacher logs in on the teacher machine and
… records attendance information while teaching. Counselor may
</html> on-line search for attendance information of his classes at any
<html> time, and verify 、 statistic and summarize attendance
<Free … information. Students can also be online searching for personal
Marker> Hello John! attendance records.

Java
B. use case analysis
… Students, teachers and counselors are the main users of the
data.name=’J system. Students can query their coursed attendance
ohn’ information. Teachers can record and query attendance
… information of students whose they are teaching in the current
semester, and modify them according to the special information
(sick leave, personal leave, etc.)provided with by counselors.
Counselors can query various courses attendance information
Figure 1. Working mechanism of FreeMarker
of students whose they are responsible for in the current
semester. Counselors and teachers can verify the special
B. Controller Layer WebWork
circumstances of the student information.
The controller layer of the system is designed by WebWork
framework. WebWork is a kind of MVC framework.
ServletDispatcher instantiates a new ActionProxy, which is IV. DESIGN AND IMPLEMENTATION OF SYSTEM
responsible for request processing. ActionProxy invokes
A. System module division
interceptor before it invokes real “Action”. Interceptors
intercept the request being sent to and returning from the The modules of attendance management system include
Action. Once execution of Action is complete, the request is importing course-plan, adding, modifying, querying, verifying
sent to a result to render the results. and summarizing attendance information.
The function of WebWork can be listed as follows in the B. Design and Implementation of system
entire system.
First, user’s request is encapsulated to a data object. 1) Presentation Layer
Second, according to different requests, the corresponding Templates are in fact programs you write in a language
logic processing unit is called. called FTL (for FreeMarker Template Language). This is a
Third, result is returned after logical processing unit has very simple language designed for writing templates.
completed A template is a mix of the text、Interpolation、FTL tag
Finally, combination of data of Result object and pre- and comment.
designed presentation is displayed to user. Code of duplication will be extracted to build a macro in
order to optimize the code structure and reduce maintenance
C. Business logical layer and data persistence layer costs while the page is written by FreeMarker. Macro of
Business logic is responsible for the calculation and FreeMarker is a template fragment associated with a variable
treatment of business logic. Data presentence is that attributes which is used through the user-defined instructions in the
of objects will be saved before the end of the life cycle of template. Through FreeMarker macro, the system page's style
objects. Business objects are managed by Spring framework in can be unified, reuse of the duplication of code, be conducive
the system, using Spring JDBC Template simplifies the use of to modify the whole style of the page. It is must that modifying
JDBC. definition of macro while modified rather than adjust one by
The role of Spring is mainly manifested in the following one.
aspects.
2) Controller Layer the corresponding page will display. Its working principle is the
WebWork actions are the central unit of programming in first interceptor to determine if there is no inheritance
WebWork. Actions are responsible for both holding Anonymous interface, log on directly to the Action.
data/state(in the form of getters and setters) and executing ExceptionInterceptor is mainly to prevent some illegal
logic. Actions are required to implement the operation caused by abnormal, such as upload files too large
com.opensymphony.xwork.Action interface. anomaly caused by a null pointer and so on.
a) Action 3) Business logical layer and data persistence layer
Two base class of Action are created in the project, one is In this system the Spring Framework Service realize the
BaseAction, the other is AnonymousAction. Actions are business logical layer, through JDBC Template to complete the
required to inherit BaseAction when it is need to log in for data processing of the persistence layer.
user. Actions are required to inherit AnonymousAction when it a) Service
is not need to log in for user. A lot of methods are defined in The base class of service named CommonBaseService is
BaseAction. These methods are used to get logged-on user created to set log and access to database. When we call Service
name, user ID, the user object (Map), user agencies and to complete the business deal, we often encounter the problem
departments where the number of such information. of wrong Service name. A class named ServiceManager is
In addition, taking into account common problems of Web defined in this system, in which get and set methods of Service
projects, BaseAction some of the public parts will be extracted are set up in order to be able to accurately call the required
to build the CommonBaseAction class that will complete return Service.
page of common results、get basic environmental information A Service named BaseService which inherit
and paging. CommonBaseService is created because each Service is
The relation among BaseAction 、 CommonBaseAction required to obtain ServiceManager. BaseService created
and Action is shown as the following: getServMgr method used to obtain ServiceManager.
public class CommonBaseAction implements Action XxxService achieves specific functions inherits BaseService in
{……} Persistence layer, such as:
public class BaseAction extends CommonBaseAction public class XxxService extends BaseService {……}
{……} b) Spring JDBC Template
When you want to create a action, first of all to create a Spring JDBC Template is the most important class of the
Java class, named XXXAction (for example, AttendAction) JDBC core package. It simplifies the use of JDBC, which deals
inherit BaseAction, then to define variables, variable type, and with the resources to establish and release. It can help
then to create the corresponding get and set methods and the developers avoid some common mistakes, for example, forgot
necessary business methods. Action is defined as follows in to close the connection. Spring JDBC Template can run the
general: core JDBC workflow, developers only need to provide SQL
public class AttendAction extends BaseAction {……} and extract results. The class can complete query/update /call
The system will call the corresponding Action in stored procedure. It can simulate the iteration of results and
accordance with the configuration file. Therefore a extract return value. It can catch the JDBC exception and
configuration file of the Action should be prepared. The convert them into a common Exception defined in
configuration file of the AttendAction is shown as follows: org.springframework.dao package.
<action name="attend" The part of code is only required to implement the callback
class="stumis.action.attendmis.AttendAction"> interface in accordance with a clear definition of a group of
<result contracts. The callback interface named
name="attendMis">attendmis.ftl</result> PreparedStatementCreator creates PreparedStatement and
</action> provides SQL and any necessary parameters. The interface
When the result of AttendAction is “attendMis”, the page named RowCallbackHandler get value from each line of data
named “attendmis.ftl” is redirected. sets.
b) Interceptors c)Transaction processing
There is a special object named interceptors which wrap The system uses DataSourceTransactionManager of Spring
around the execution of the action and the result in WebWork. as the transaction administrator. The code associated with the
Interceptors allow you to do some processing before and / transaction management is not directly appeared in the Service,
or after the action and result are executed, and they also let you instead of using a declaratory management.
modularize common code out into reusable classes. TransactionProxyFactoryBean is used to designate transaction
Interceptors have been called before Actions are management objects and their methods. Transaction
executed.Interceptors determine whether the implementation of management will use transactionAttributes to automatically
Action or how to implement the Actions. They can complete a designate methods.
series of work as security, log and check and so on. V. CONCLUSION
Two interceptors are defined in the system except for built-
in interceptors of WebWork, one is the LoginInterceptor, the The paper aims at the research of Web technology, as well
other is ExceptionInterceptor. LoginInterceptor prevents non- as the attendance management system based on the campus
logged-on user access. When the user does not log on and network for all college students is implemented. The student
direct input a page address, intercept mechanism will work and attendance management system will guarantee the teacher and
redirect the login page. Only when users log on successfully, the counselor can gain timely and quickly the attendance
information of students. The system has been successfully [4] Z. M. Yu, L. C. Xie and X. Y. Han, “Research on a Web metadata
applied in campus by testing and debugging. This will provide extraction method”, Microcomputer Information, Beijing, vol. 24,
pp.232–234, Nov . 2008.
a new way to strengthen the student management.
[1] T. B. Hu and J. K. Ye, “Simulation system of WebGIS based on MVC [5] Seth Ladd,Darren Davison,Steven Devijver and Colin Yates, Expert
pattern ,” Application Research of Computers. Chengdu, vol. 26, Spring MVC and Web Flow Apress . Apress ,2006.
pp.247–249, Jan .2009. [6] D. Y. Shi, Management Information System. Publishing House of
[2] W. P. Wu, L. F. Wang and Z. J. Jiang, “Research of controler in Web Electronics Industry, 2006.
application based on MVC”, Microelectronics & Computer, Xian, vol. [7] H. C. Bi and X. K. Li, “Design and research of the Web project based
25, pp.182–184, May 2008. on Spring+Struts+Hibernate framework”, Computer Development &
[3] Lightbody, Patrick/ Carreira and Jason , WebWork in Action. Oreilly & Applications, Taiyuan, vol. 21, pp.51–52, Apl. 2008.
Associates Inc ,2005. [8] B. Qi and L. Y. Xu, “The Implement of IoC in Springframework”,
Microprocessors,Shenyang, NO. 1, pp.147–149, Feb. 2008..

You might also like