Sei sulla pagina 1di 64

ABSTRACT

Online Examination System is aimed at computerizing the activities involved in


Examination. The primary activities in the exam include importing the question paper,
generating the reports and taking the backup.

This project includes the following Modules:

1. Administrator module

This module deals with the Question paper importing, Student list importing, Student
userid and password generation, Report generation, User blocking and Unblocking and
taking the backup.

2. Student Module

This module deals with the student logging into the system and taking the exam.
INDEX

1. INTRODUCTION

2. REQUIREMNETS

3. DESIGN

4. TESTING & TEST CASES

5 SCREEN SHOTS

6 JAVA EE 5 (J2EE 1.5), JSP, SERVLET, TOMCAT

7. BIBLIOGRAPHY
INTRODUCTION

This is the project work undertaken in context of partial fulfillment of Diploma in


Advance Computing. We have tried our best to make the Online Examination Software
system as simple as possible using structured, modular & with better user interface. This
project is used by two types of users:

i. Students.
ii. Administrator.

The student can login into the system with the userid given to him by the
administrator to take up the exam. He is provided with the question and choices through
which he can select the answers for each question. He is able to move back to the
previous question and can change the previously selected answers.

The administrator can import the question paper, import the student list and
generate the userid & password, generate the reports and take printouts. Administrator
can generate the marks report of the particular user. Administrator can generate the rules
& instructions for each exam.The administrator can also set the time for each
examination. Administrator is able to take the backup of the question paper and also the
details of the student
REQUIREMNETS

Modules
1. Student
2. Administrator

1. Student
1.1 Login
1.2 Post Login
1.3 Instruction
1.4 Examination
1.5 Completion

1.1Login
1.1.1 In login page student have to use the login which was given before
exam and generated by administrator.

1.1.2 Unique id and password will be provided to each student

1.1.3 If user enters wrong password then a message will be generated


that password is wrong.

1.1.4 If student enters wrong userid then in such case a message will
displayed- userid is invalid.

1.1.5 If student login successfully then post login page will displayed
1.2 Post login
1.2.1 User information page will be displayed where Following
information will be displayed
A) Name of the student
B) Roll number of student
C) Course name

1.2.1 After info page there will be exam specific information/ instruction
page.

1.3 Instruction
1.3.1 In this scenario all instruction about the exam will be displayed to
user.

1.3.1 In admin instruction all the info given by the admin will be shown.
The information of admin saves in a file (instruction.info) and it
contain instruction about the exam like number of questions, time,
negative marking etc.

1.3.2 Admin info will be loaded from that file by the admin.
1.4 Examination

1.4.1 First region is header region where name of the exam and institute
name etc information will be displayed.

1.4.2 In right top corner region, there will be a timer which show the
remaining time of exam

1.4.3 Second region contain the question and options. Each question has
four choices. There are checkboxes for each choice,checking the
checkbox selects the answer for that question.

1.4.4 In third region there will be just like a status bar where the
information related to paper will be displayed like number of
questions , total answered questions, unread questions etc. Which
help user to find his/her status.

1.4.5 In fourth region, there will be rectangular boxes with question


number in them .User can click on question of his choice.
Rectanglar boxes are of three colors.

a. Black – black colour represent that question is still unread


b. Red – red colour represent that question is read but unanswered.
c. Green – green colour represent that question has been answered.
Example:
3
Question 3 is answered

3 Question 3 has been read yet not answered

3 Question 3rd is unread

1.4.6 user clicks on the next button to get the next question

1.4.7 user clicks on the submit button to save the answer and move to
the next question

1.4.8 A quit button is provided for the user to end his exam

1.5 completion

1.5.1 After completion of time or when user clicks on quit button


browser will be closed and a thank you message will be displayed

1.5.2 Once given the exam he is not able to login again using that id and
password as that id will be blocked after that.
2. Administrator
2.1 Examination Section
2.2 Report Scenario
2.3 backup scenario
2.4 settings scenario

2.1 Examination

2.1.1 Import student list

2.2.1.1 the student list format should be in the CSV format (Comma
separated values).

2.2.1.2 The .csv file contains three columns they are student name,rollno
and the course name.the roll no is unique for each student.

2.2.1.3 Once uploaded the student list will be saved in database.

2.1.2 Import Question paper

2.1.2.1 the questionpaper should be in the CSV format (Comma separated


values).

2.1.2.2 Once uploaded paper will be save in database. After that when
exam or test will start they will be loaded automatically.

2.1.2.3 Each question will have unique id.


2.1.3 Gwenerate the rules

2.1.3.1 Admin can set the time duration of the exam,set the
marks/question,set the neagative marking for each question ,set the
exam name .

2.1.3.2 All the rules related to exam are saved in the file
(admininstuction.iif).

2.1.3.3 These rules will be shown to user, before the start up of the exam

2.1.4 Userid and password Generation

2.1.3.1 Userid and password for different students are generated by


administrator

2.1.3.2Userid will be based on course name like if he is generating login


for ‘dac’ course then userid will have “DAC” as initial after that
there may be a number from a range selected by user like may be
between 1 to 1000 or 1000 to 2000.

Example: ‘DAC2003’

2.1.3.3 Password also randomized from selected range and after selecting
the number it will be converted into hex code and that will be
password for that particular userid.
Example: like the number range is 50000 to 100000 . and selected
number is 63577. Then in such case password will be ‘E445’ as
this code is hex code of selected number.

2.1.3.4 By default status of each user is blocked.

2.1.4 unblock all users

2.1.4.1 admin can unblock the users before the exam starts

2.2 Report
2.2.1 Question Paper print
2.2.2 Complete mark sheet of particular course
2.2.3 Mark sheet of individual student.
2.2.4 Userid and password list
2.2.5 Show instructions

2.2.1—Question paper print out

• Question paper of particular course can be printed.


• Question paper can also be printed with answers.

2.2.2—Complete mark sheet

• Mark sheet of all students of particular course can be get.


• Mark sheet will be generated after the finishing of the exam
so that there is no need of students to wait for the results long
time.
• This sheet will contain roll number, name of the student,
their marks, percentage and status like whether he /she failed,
passed or absent.

2.2.3 – Mark sheet of individual student by taking the roll number of the
student

• Mark sheet of individual student can also be printed.


• This will be printed only on need basis.
• This option is provided to administrator because if there is
some mistake in marks of any student. Or we can say that if
somebody claims to show his answers.
• This mark sheet will contain all the questions, answers
given by student and actual answers.

2.2.4 userid and password list

• These userid’s and passwords generated by administrator

2.2.5 displays the instruction generated by the admin for the particular
exam

2.3 backup
2.3.1 In this scenario backup of the question paper is taken and the student list and
also the answers by the student and stored in the master table and the
generated userid and password are blocked

DESIGN
Class Design

The classes used in this project are as follows…

• public class AdminLogin implements Serializable


private String userid;
private String password;
get-set methods

• public class businessLogic<studentDetails> implements


businessLogicInterface

public String checkUser(HttpServletRequest req)


this function is used to validate the user/student.

public String readInstrutions(HttpServletRequest req)


this function reads the instruction from the file which are shown to the user at the
login page.

public String loadQuestionPaper(HttpServletRequest req)


this function reads the question paper returned from the database.

private void saveInstructionsIntoTheMap(HttpServletRequest


req,String instructions)
this function calls the read instruction fuction.
public String saveMyAnswer(HttpServletRequest req)
this function converts the answer string into the array of answers.

private int[] getMyRollAndAnswer(String userAnswer)


this function stores the student roll number and his answers into an array.

private int getIntoInteger(String userAnswer)


this function converts answerstring variable into integer.

public String ReadInstruction(HttpServletRequest req)

private Map<Integer, String> saveInstructionInMap(String instructions)


this function reads the instruction from the file and stores them into the map where
key is the instruction number and value is the instruction.

public String AdminLogin(HttpServletRequest req)


this function is used to validate the administrator.

public String loadPaper(HttpServletRequest req)


this function reads the question paper to store into the database.

public String UnBlockAllUsers(HttpServletRequest req)


the is function is used to unblock all the users before taking the exam.

public String BlockAllUsers(HttpServletRequest req)


this fuction is used to block all users.

public String loadStudent(HttpServletRequest req)


public String GenerateIdAndPasswords(HttpServletRequest req)
this function is used to generate userid and password.

public String saveRules(HttpServletRequest req)

public String printResultSheet(HttpServletRequest req)


this function is used to print result sheet.
public String loadMarkSheetWithQuestionPaper(HttpServletRequest req)
this function is used to print the question with answers.

public class checkCSVfile


methods:--

public static Boolean checkCSV(String filepurpose)


this function is used to check whether the file is in csv format or not.

• public class Configure implements Serializable

private String instituteName;


private int hour;
private int minute;
private int marksPerQuestion;
private double negativePerQuestion;
private String instructions;
methods:--
get-set methods
public Configure(String instituteName, int hour, int minute, int marksPerQuestion,
double negativePerQuestion, String instructions)

• public class dbutility


public static Connection get()throwsIllegalArgumentException
this function is used to get the database connection.

• public class ImportingFiles


public static Question[] importQuestionPaper(String fileName)
this function is used to read the questions from the database and store it into the
question array.

public static studentDetails[] importStudentTable(String filename)


this function is used to read the student details from the database and store it into the
student array.
• public class InstructionWriting

public static void writeInstructions(Configure config) throws


IllegalArgumentException

• public class LoginClass

private int roll;


private String userid;
private String password;
get-set methods
• public class LowerLayer implements LowerInterface

public String checkUSer(LoginClass obj) throws SQLException

private String checkTheOtherOptions(Connection con, ResultSet rs,String password)

private void UpdateStatusOfUser(int roll, Connection con)

public Map<Integer, String> getAllDetailsOfUser


(String userid)

public Configure getRules() throws IllegalArgumentException

public Map<Integer, Question> LoadQuestions() throws IllegalArgumentException

public void getMyResult(int[] ans) throws IllegalArgumentException

private void ConvertToMapAndSave(int[] ans)

private void findResultAndSave(int[] ans) throws llegalArgumentException


private void saveToDataBase(int roll, double result)

public String checkAdmin(AdminLogin obj) throws IllegalArgumentException,


FileNotFoundException
public void loadPaperFromFile(String filename)throws IllegalArgumentException,
SQLException

private void doBlockAndUnBlock(String U)

public void unBlockAll() throws IllegalArgumentException {

public void BlockAll() throws IllegalArgumentException {

public void loadStudentsFromFile(String fileName)


throws IllegalArgumentException, SQLException

public void generateIdAndPassword() throws


IllegalArgumentException,SQLException

private LoginClass[] generateIDsAndPasswords(int totalStudents,String courseName,


List roll)

private boolean checkValue(String userid, LoginClass[] obj)


public void saveAllRules(Configure config) throws IllegalArgumentException

public Map getResults() throws IllegalArgumentException, SQLException

public int[] getMarkSheet(int roll) throws IllegalArgumentException

• public class Question implements Serializable


private int questionId;
private String ques;
private String option1;
private String option2;
private String option3;
private String option4;
int answer;
SET -GET METHODS
• public class ReadAdminInstruction

public Configure readInstructions(String filename) throws IllegalArgumentException

• public class ReadInstructions

public Configure getRules() throws IllegalArgumentException

• public class studentDetails implements Serializable


private int rollNumber;
private String name;
private String courseName;
private String studentAnswer;
private double marksOfStudent;
public studentDetails(int rollNumber, String name, String courseName, String
studentAnswer, double MarksOfStudent)

SET-GET METHODS..

• public class studentread


public static studentDetails[] importmycsv(String filename)

• public class Utility


public static void log(String string)
public static int getInteger(String value)

• public class writeToFile


public static changepassword(string p)

Class Diagram
E-R Diagaram

password rollno name


password

userid
userid courseName

lls
enro
Student Admin

k n
ta co uct
es d
s

Exam

exami questionpape
studentmap
d r
Interface Design.
There are only two major interfaces used in the project they are
1) businesslogic layer interface is present between the business logic layer and the
presentation layer

<<interface>>
BusinessLogicInterface

• String checkUser(HttpServletRequest req);


• String readInstrutions(HttpServletRequest req);
• String loadQuestionPaper(HttpServletRequest req);
• String saveMyAnswer(HttpServletRequest req);
• String ReadInstruction(HttpServletRequest req);
• String AdminLogin(HttpServletRequest req);
• String loadPaper(HttpServletRequest req);
• String UnBlockAllUsers(HttpServletRequest req);
• String BlockAllUsers(HttpServletRequest req);
• String loadStudent(HttpServletRequest req);
• String GenerateIdAndPasswords(HttpServletRequest req);
• String saveRules(HttpServletRequest req);
• String printResultSheet(HttpServletRequest req);
• String loadMarkSheetWithQuestionPaper(HttpServletRequest
req);
<<interface>>
LowerLayerInterface
String checkUSer(LoginClass obj) throws SQLException ;
Map<Integer, String> getAllDetailsOfUser(String userid);
Configure getRules() throws IllegalArgumentException;
Map<Integer, Question> LoadQuestions()throws
IllegalArgumentException ;
void getMyResult(int[] ans) throws IllegalArgumentException;
String checkAdmin(AdminLogin obj) throws
IllegalArgumentException, FileNotFoundException ;
void loadPaperFromFile(String fileName)throws
IllegalArgumentException, SQLException ;
void unBlockAll() throws IllegalArgumentException;
void BlockAll() throws IllegalArgumentException;
void loadStudentsFromFile(String fileName)throws
IllegalArgumentException, SQLException;
void generateIdAndPassword() throws IllegalArgumentException,
SQLException;
void saveAllRules(Configure config) throws
IllegalArgumentException;
Map getResults() throws IllegalArgumentException, SQLException;
int[] getMarkSheet(int roll)throws IllegalArgumentException,
SQLException;
class
2) The Lower layer interface is present between the storage class and the businesslogic
UI Screens:

Admin Login Page:


Admin Post Login Page:
Exam Section Page:
Instruction Page;
Load Question Paper Page:
Back Up Page:
Change Password Page:
Restore Page:
Report Section Page:
Student Module Pages:
Student Login page:
Student Details Page:
Student Instruction Page:
Student Examination Start Page:
Student Examination Page:
Post Exam Page:
Database table

Login table
Userid password Rollno status
varchar varchar number varchar
FK

Userid –the Id generated by the administrator


Password- the pwd of the user generated by the administrator
Rollno –the rollno of the student it is the foreign key
Status- tells wheteher user is Blocked,
Not LoggedIn

Student table

Rollno Name Paperset Marks


Number varchar Varchar Number
PK

RollNO: Roll No. of the student used to uniquely identify the student and is made as
primary key of the Student table.
Name:It holds the Student Name.
Marks:Marks field hold the marks of the student.

Question Table
Qid Question CH1 CH2 CH3 CH4 Ans
Number Varchar Varchar Varchar Varchar Varchar Number
PK

Qid:Qid Field is made as Primary key of the Question table.


Question: Question field contains the Questions of the test.

CH1:This filed contains the first Option for the corresponding Question

CH2:This filed contains the second Option for the corresponding Question

CH3:This filed contains the third Option for the corresponding Question

CH4:This filed contains the fourth Option for the corresponding Question

Ans: CH1:This filed contains the Answer for the corresponding Question

MasterData Table

ExamDate Module questionmap studentmap


date varchar Longblob longblob

Primary Key= ExamDate,Module


Module-it Uniquely identifies the module.
ExamDate-identifies the date of the exam.
questionmap-map containing the question paper.
Studentmap-Map containing the answer of all student.

DummyStudent table
Rollno Name Paperset Marks
Number varchar Varchar Number
PK

this table contains student information used for report generation.

Dummy Question Table

Qid Question CH1 CH2 CH3 CH4 Ans


Number Varchar Varchar Varchar Varchar Varchar Number
PK

this table contains question paper used for report generation.


trigger used
DELIMITER |
CREATE TRIGGER mastertrigger
AFTER INSERT
ON MASTER
OR EACH ROW
BEGIN
DELETE FROM logintable;
DELETE FROM studentdetails;
DELETE FROM questionpaper;
END;

TESTING

what is testing?

 process used to help identify the correctness, completeness and quality of


developed computer software.
 Find out difference between actual and expected behavior.
 The process of exercising software to verify that it satisfies specified requirements
of end user and to detect errors
 The process of revealing that an artifact fails to satisfy a set of requirements
 Establishing confidence that a system does what it is supposed to do
 Confirming that a system performs its intended functions correctly
 Does not guarantee bug free product
 No substitute for good programming
 Can’t prevent/debug bugs, only detect
 Offer advise on product quality and risks.

why testing?
• Detect programming errors:- Even though we have best developers
developing the product still there may be flaws somewhere due to
misconception, due to lack of understanding in integrating modules of 2
great developers. Most of the time developers think that their code is
perfect, it cannot have bugs and that’s where the problem is. They think
that finding bugs in their code means that some one is proving them
inefficient. Hence we test code not to prove a developer inefficient but to
find bug in code not in developer.
• Testing at earlier stage is much cheaper than testing at later stage.
• If Client find bugs which were uncovered earlier then we loses credibility
and may lose business as well.
• There are several functionality related that occur in real life scenarios
related only so while testing at customer site during beta testing we can
uncover these defects there and then.
• To release a bug free product seems to be a dream yet to be fulfilled,
hence it is a real challenge to release a product that is bug-free.
TESTCASES

Caseid Scenario Input Expected Actual Result Comments


Output output
1.1 Login Either Error yes
Scenario userid or message-
password Fields are
is blank mandatory,
Remains in
Login Page
Userid is Error yes
Wrong message-
Invalid userid
Password Error yes
is Wrong message-
password
Mismatch
Both User Details yes
userid page will be
and displayed
password
are
correct
User Error yes Account is
with message- already in
same use
account “already in
is already use”
logged Remains in
in. Login Page
1.2 Post login Click on Instruction yes
Scenario next page is
button displayed
1.3 Instruction Click on User Details yes
Scenario back page will be
displayed
Click on Startup page yes Startup page
Next will be will have
Button displayed two buttons-
Back and
Start Test
1.3.1 Pre- Click on Instruction yes User can
Examination Back page is read
Startup Button displayed Instructions
Scenario
Click on Examination yes When user
Start Test page will be clicks on
Button displayed start test
button, test
timer starts
1.4 Examination User Corresponding yes Every
Scenario clicks on Question will question
Question be displayed number is
Number the hyperlink
User Corresponding yes Red color
clicks on Question box means,
submit number will Question has
without be surrounded been read
selecting with red color but not yet
any box and next answered
Option question will
be displayed
User Corresponding yes Green color
clicks on Question box means,
submit number will Question has
with be surrounded been
selecting with green answered
any color box and
Option next question
will be
displayed
1.5 Completion User As simple yes Summary
Scenario Clicks on Message will page will
Quit be displayed have total
button number of
before questions
timer answered
expiries and
unanswered.
If timer As simple yes
expiries Message will
before be displayed

ADMIN TESTCASES

Caseid Scenario Input Expected Actu Result Comments


Output al
outp
ut
2.1 Login Either userid Error message- yes
Scenario or password Fields are
is blank mandatory,
Remains in
Login Page

Userid is Error message- yes


Wrong Invalid userid
Password is Error message- yes
Wrong password
Mismatch
Both userid 58766 error yes 58766
and password code will be error code
are correct displayed means the
but file is file where
missing. userid and
password
are saved is
missing.
Both userid Post Login page yes
and password will be
are correct displayed
2.2 Administrator Page will be yes By Default
Post Login displayed that Instruction
Scenario contains four will be
buttons Exam displayed
Section,Report for the
Section,Backup, Admin.
Help,Logout.

2.2.1 Exam Section Import Load Student yes I


Scenario Student button will
List-- Enable
When admin
clicks on
Import
Student List,
Admin can
Import
student list
file through
Dialog box
only in CSV
format.
When clicks Message will yes
on Load display-please
Student load only csv
Button and If format file
file is not in
csv format.
When clicks Message will yes
on Load display-Its not a
Student proper file.
Button and If
file is in csv
format but
not in
required
format.
When clicks Message will yes All Record
on Load display- student of file will
Student list loaded be saved in
Button and If successfully and database.
file is in csv Load Button
format and will disabled
also in
required
format.
Import Load Paper yes
Exam Papers button will
When admin Enable
clicks on
Import paper,
Admin can
Import test
paper file
through
Dialog box.
When clicks Message will yes
on Load display-please
Paper Button load only csv
and If file is format file
not in csv
format.
When clicks Message will yes
on Load display-Its not a
Paper Button proper file.
and If file is
in csv format
but not in
required
format.
When clicks Message will yes All
on Load display-Paper question
paper Button loaded will be
and If file is successfully and saved in
in csv format Load paper database.
and also in button will
required disabled
format.
When clicks Rule Section yes Rule
on Generate will display. Section
Instructions will have
button. Time,Mark
s, Negative
marks and
Instruction
field.
When clicks Particular yes
on SaveRules message will
button and if display
value entered according to
in each fields field.
are not
according to
condition
When clicks Message will yes
on SaveRules display-Rules
button and if generated
value entered successfully.
in each fields
are according
to condition
When clicks Text area for yes
on Clear instruction will
button. be cleared.
when clicks Exam Section yes
on Cancel page will
button display.
When clicks Message will yes
on Generate display-Please
Now button import student
and student list first.
list is not
imported
when clicks Message will yes
on Generate display-Already
Now button userid and
and if password
logintable is generated first
not empty do backup.
when clicks Message will yes Userid
on Generate display-userid with dac
Now button and password prefix and
and if generated. password
logintable is will be
empty generated
and saved
in
logintable.
when clicks Message will yes
on UnBlock display-please
All button import student
and student list first.
list is not
imported.
when clicks Message will yes All
on UnBlock display-students students
All button unblocked will be
and student successfully. unblocked
list is already and they
imported. can login
now.
2.2.2 Report When clicks Result sheet yes Admin can
Section on will display take print
Scenario ResultSheet with Print out of
button Report and Exit result sheet
button
When clicks Question sheet yes Admin can
on Question will display take print
Paper button with Print out of
Report and Exit question
button. sheet
When clicks Userid and yes Admin can
on userid and password sheet take print
password list will display out of
button with Print userid and
Report and Exit password
button. sheet
when clicks Whatever yes
on show Instructions
Instructions given by the
Admin will
display.
when clicks Message will yes
on mark display-Roll
Sheet and roll Number not
number given found.
in textbox is
not a valid
roll
when clicks Question paper yes In case
on mark sheet with student
Sheet and roll correct answer complain
number given and answer then
in textbox is given by the Admin can
a valid roll student will take print
display with out of
print report and question
exit button paper sheet
with
answer
given by
student.
2.2.3 Backup When clicks Message will yes Now no
Section on Block All display-students student can
Scenario button Blocked login again
successfully. with given
userid and
password
Instruction yes Contains of
Generation- the
Admin can instruction
select the file will be
instruction displayed
file through on the
the dialog instruction
box, page.
When Admin
clicks on
Generate
Instruction
button,
Instructions
file will be
imported.
Get Test Printouts will be yes Admin Can
Paper generated. take
Printout- printout
When Admin with and
clicks on without
Print Paper answers
button,
printouts will
be generated
2.2.2 Result Complete yes Admin can
Section Result sheet- take the
Scenario When Admin printouts of
clicks on result
Result Sheet sheet.
button,
Students
result will be
displayed

Individual yes Admin can


Result Sheet- take the
When Admin printouts of
clicks on Individual
Particular student
Student result
Result button, sheet.
Individual
Student result
will be
displayed

2.2.3 Settings Change yes


Scenario useid and
password-
When Admin
click on this
button Admin
can set new
Id and
Password.
Set Institute Header and yes
name(header footer will be
and footer) changed to
Admin can specified text in
enter header all the pages
and footer
text into
correspondin
g textbox and
clicks on set
button

2.2.4 Logout When admin yes


clicks on
Logout,he
will come out
of
Application
DATA BASE

Database is similar to a data file in that it is a storage place for data like a data,
database not present information directly to a user. The user runs an application that accesses data
from the database and presents it to the user in an understandable format.

Database system is more powerful than data files. The data is more highly organized, in a
well designed database, there are no duplicate pieces of data that the user or application
has to be update at the same time. Related pieces of data are grouped together in a single
structure or record, and relationship can be defined pieces of data are grouped together in
a single structure or record & relationships can be defined between there structures &
record.

When working with data files an application must be coded to work with the specific structure of
each data file. In contrast each database contains a catalog that applications use to determine how
data is organized generic database application can use that catalog to present user with the data
from different database dynamically without being tied to a specific data format.

A database typically has two components the file holding the physical database and the database
management system (DBMS) software that application use to access data, The DBMS is
responsible for enforcing the database structure including-

• Maintaining the relationship between data in the database.

• Ensuring that data is stored correctly & that the rule defining data relationship is not
violated.

• Recovering all data to point of unknown consistency in case of the system failures.

MySQL is currently the most popular open source database server in existence
JAVA EE 5, JSP, TOMCAT

JAVA EE 5

Java EE 5 is a strong, significant release, making it the most complete platform for
enterprise development.

JSP

A JSP page is a text document that contains two types of text: static data, which can be
expressed in any text-based format (such as HTML, SVG, WML, and XML), and JSP
elements, which construct dynamic content.

The recommended file extension for the source file of a JSP page is .jsp. The page can
be composed of a top file that includes other files that contain either a complete JSP page
or a fragment of a JSP pageThe JSP elements in a JSP page can be expressed in two
syntaxes, standard and XML, though any given file can use only one syntax. A JSP page
in XML syntax is an XML document and can be manipulated by tools and APIs for XML
documents

JavaServer Pages (JSP) technology allows you to easily create web content that has both
static and dynamic components. JSP technology makes available all the dynamic
capabilities of Java Servlet technology but provides a more natural approach to creating
static content.

The main features of JSP technology are as follows:-

A language for developing JSP pages, which are text-based documents that describe how
to process a request and construct a response.An expression language for accessing server-
side objects.Mechanisms for defining extensions to the JSP language
Java Servlet Technology

A servlet is a Java programming language class that is used to extend the capabilities of
servers that host applications accessed by means of a request-response programming
model. Although servlets can respond to any type of request, they are commonly used to
extend the applications hosted by web servers. For such applications, Java Servlet
technology defines HTTP-specific servlet classes.

Servlet Life Cycle

The life cycle of a servlet is controlled by the container in which the servlet has been
deployed. When a request is mapped to a servlet, the container performs the following
steps.

1. If an instance of the servlet does not exist, the web container


a. Loads the servlet class.
b. Creates an instance of the servlet class.
c. Initializes the servlet instance by calling the init method. Initialization is
covered in Initializing a Servlet.
2. Invokes the service method, passing request and response objects. Service methods
are discussed in Writing Service Methods.

If the container needs to remove the servlet, it finalizes the servlet by calling the servlet’s
destroy method.

Handling Servlet Life-Cycle Events

We can monitor and react to events in a servlet’s life cycle by defining listener objects
whose methods get invoked when life-cycle events occur. To use these listener objects
you must define and specify the listener class.

The javax.servlet and javax.servlet.http packages provide interfaces and classes


for writing servlets. All servlets must implement the Servlet interface, which defines
life-cycle methods. When implementing a generic service, we can use or extend the
GenericServlet class provided with the Java Servlet API. The HttpServlet class
provides methods, such as doGet and doPost, for handling HTTP-specific services.

Model–view–controller

Model–View–Controller (MVC) is a software architecture, currently considered an


architectural pattern used in software engineering. The pattern isolates "domain logic"
(the application logic for the user) from input and presentation (GUI), permitting
independent development, testing and maintenance of each.

The model is used to manage information and notify observers when that information
changes. The model is the domain-specific representation of the data upon which the
application operates. Domain logic adds meaning to raw data (for example, calculating
whether today is the user's birthday, or the totals, taxes, and shipping charges for
shopping cart items). When a model changes its state, it notifies its associated views so
they can be refreshed.

Many applications use a persistent storage mechanism such as a database to store data.
MVC does not specifically mention the data access layer because it is understood to be
underneath or encapsulated by the model. Models are not data access objects; however, in
very simple apps that have little domain logic there is no real distinction to be made.
Active Record is an accepted design pattern which merges domain logic and data access
code - a model which knows how to persist itself.

The view renders the model into a form suitable for interaction, typically a user interface
element. Multiple views can exist for a single model for different purposes. A viewport
typically has a one to one correspondence with a display surface and knows how to
render to it.
The controller receives input and initiates a response by making calls on model objects.
A controller accepts input from the user and instructs the model and viewport to perform
actions based on that input.

An MVC application may be a collection of model/view/controller triplets, each


responsible for a different UI element.

Java: Java Platform, Enterprise Edition (Java EE)

Simple Version implementing Java Servlets and JavaServer Pages from Java EE:

Model
The model is a collection of Java classes that form a software application intended
to store, and optionally separate, data. A single front end class that can
communicate with any user interface (for example: a console, a graphical user
interface, or a web application).
View
The view is represented by a JavaServer Page, with data being transported to the
page in the HttpServletRequest or HttpSession.
Controller
The Controller servlet communicates with the front end of the model and loads
the HttpServletRequest or HttpSession with appropriate data, before forwarding
the HttpServletRequest and Response to the JSP using a RequestDispatcher.

The Servlet is a Java class, and it communicates and interacts with the model but does not
need to generate HTML or XHTML output; the JSPs do not have to communicate with
the model because the Servlet provides them with the information—they can concentrate
on creating output.
TOMCAT:

Apache Tomcat (or Jakarta Tomcat or simply Tomcat) is an open source servlet
container developed by the Apache Software Foundation (ASF). Tomcat implements the
Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and
provides a "pure Java" HTTP web server environment for Java code to run.

Tomcat should not be confused with the Apache web server, which is a C implementation
of an HTTP web server; these two web servers are not bundled together. Apache Tomcat
includes tools for configuration and management, but can also be configured by editing
XML configuration files.

Potrebbero piacerti anche