Student Java Online Documentation Advanc
Student Java Online Documentation Advanc
In collaboration with
Abstract
This report is an attempt to delineate and discuss two major concepts, Java Server Pages and Java Database
Connectivity (accomplished through MS Access), implemented by the powerful and dynamic technology
called Java 2 Enterprise Edition. A thorough quantitative investigation of this technology is conducted via a
novel project that coincidently, focuses on a student’s requirement for a concise representation of the
knowledge needed to understand the heart of Java namely, is the Java 2 Standard Edition.
1
Acknowledgement
We are grateful to Ms. Deepa Ashok Kumar (J2EE lecturer and project supervisor) not only for her
invaluable guidance but also for her unending encouragement that she has given to me throughout the J2EE
course and project. This work is a reflection of her teachings and expertise in the subject that she has
passed on to us. This course and project has been challenging and most enthralling experience. We
sincerely thank her for her patience, humour and knowledge, and hope to continue forward to better and
more exciting days with our careers.
As I, Rahul Dass, am submitting this documentation first on behalf of my team. I declare that the above
acknowledgement and this documentation along with this project: ‘Java online documentation’ in its
entirety is truthful, honest and in complete reflection of my team members, Sayantani Banerjee
(WBGHJI5901) and Arnab Mukherjee (WBGHBW7350).
Signature of student
____________________
2
Table of contents
Chapter 1: Introduction.
3.3.2 MCQ.
4.4 MCQ.
Chapter 5: Conclusion.
Chapter 6: References.
3
Chapter 1: Introduction.
The motivation that propelled this project: ‘Java online documentation’, was predominately based on
exploring the possibilities of a powerful member of the Java platform, namely, the Java 2 Enterprise
Edition (J2EE). The J2EE application and architecture is an established piece of software that is renowned
for being robust in its core foundation: supporting multi-tier web applications and many types of clients
that can run on various computing devices. With a vision of inheriting the plethora of advantages that
comes with the core of the Java platform: Java 2 Standard Edition (J2SE), which is solely devoted to
building desktop applications and experiences, J2EE is a unique technology that targets the needs of a web-
oriented Java experience within the framework of an enterprise model.
This project was primarily focused in implementing two aspects of the J2EE technology: Java Server
Pages (JSP) and Java Database Connectivity (JDBC). The purpose of using JSP is to handle and create
dynamic web content. What makes this component of the technology ideal for handling the client side
requirements of this project is by enabling the java code to be written with html code, thus being embedded
together, thus eliminating the need for creating two separate files that are dedicated for java and html code
respectively: resulting to a high performance in the execution of the web application from a client-side
perspective. One of the key components of the JSP Application Programming Interface (API) is the fact
that it has access to another API within the J2EE technology called JDBC. This is the nature by which the
client-side communicates with the server-side aspects of the web application. In this project, we are using
the software ‘Microsoft Access’ to handle the database requirements.
Now that we have given a brief overview of the technology and its respective components that we are
implementing, the focus should now be what the ‘Java online documentation’ is all about?
In this project, the motivation is to create a database of a small selection of topics concerning the core
J2SE technology and provide a user with access to concise and succinct information with regard to those
topics. The user, ideally, being a student would first have to provide a username and password
combination, register himself/herself in order to have any access to the database. Once the student has
logged in, there is a default set of 4 topics, in the form of hyperlinks, which would take the student to the
respective information concerning the topics in the form of questions and answers that we as students
would ask when first presented with such topics. From an admin point of view, the three of us as founders
of this project, have additionally given ourselves the privilege to insert and update topic names from the
user/admin homepages. The nature of such data manipulation has stemmed from the fact that through the
web application itself, we are able to dynamically insert new and modify old data into the MS-Access
database, without having to actually go to MS-Access itself and perform any changes in data in the window
application.
Finally, we conclude this report by stating the future scope that we would have loved to implement,
however due to the complex nature of the code, ambition intentions of the project and severe time
constraints, we were unable to explore more exotic possibilities.
However, considering the project as a whole: the ‘Java online documentation’, we believe that we have
self-explored and taken the knowledge gained during lectures to the next level. By constantly challenging
ourselves to better design and implement our code, while especially during the ‘debugging’ phase of the
project, having to force ourselves to think for solutions to errors: helped us gain tremendous self-
confidence and invaluable experience when dealing with a large-scale project for the first time in our
careers.
4
Chapter 2: Design view of project tables.
In this chapter, we present the design structure: field names and their respective data types, for the four
major tables that were used in this project.
a) Login table
id Text
password Text
re-pass Text
user_type Text
b) Topic table
topic_id Number
topic_name Text
c) Details table
qs_no Number
topic_id Number
Question Memo
Info Memo
d) MCQ table
Topic_id Number
Ques_Num AutoNumber
Question Text
5
Option A Text
Option B Text
Answer Text
DFD
View,
insert
View
Online
Java
User
Documentation
Admin
Update,
delete
6
If the user gives an invalid username/password combination, the appropriate error-handling message will
be posted for the user:
If the user does not select any options, the appropriate error-handling message will be posted for the user:
7
Login page JSP code:
<html>
<head>
<title>Login Page</title>
</head>
<body bgcolor="WhiteSmoke">
<table align="center">
<tr><td align="right">
</table>
<fieldset>
<table>
</table>
</fieldset>
</form>
<%!
Connection con;
Statement st;
ResultSet rs;
8
String id,pass,utype,invID;
%>
<%
try
id=request.getParameter("username");
pass=request.getParameter("password");
utype=request.getParameter("usertype");
if(request.getParameter("submit").equals("LOGIN"))
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
if(rs.next())
invID="";
if(utype.equals(rs.getString(6)))
session.setAttribute("username",id);
session.setAttribute("password",pass);
if(utype.equals("a"))
%>
9
<jsp:forward page="admin_home.jsp"/>
<%
else if(utype.equals("s"))
%>
<jsp:forward page="user_home.jsp"/>
<%
else
invID="Invalid login";
out.println(invID);
else
out.println("Userid/password mismatch");
else
}catch(Exception e){ }
%>
</table></body></html>
In this section, a new user would first have to register himself/herself in order to access the database, by
clicking on the ‘Not a user!Sign up!’ hyperlink. The user will be redirected to a new page where there is a
‘registration form’, to fill in the user’s details. The data that the user enters will be saved in the ‘Login
table’, whose structure was defined in Chapter 2. After the user has completed inputting the data, by
clicking on the ‘Click here to sign in!’ hyperlink, the newly created user will be redirected again to a fresh
login page to sign in.
10
It should be noted that, other than the three authors of this project, all registered users would be given the
privilege of a user. By implementing the concept of sessions, once the user has logged in, they would have
a restricted access to the database, as compared to an administrator: representing each of the three authors
of this project.
apshot:
NewUser.jsp code:
<html>
<head>
</head>
<body bgcolor="WhiteSmoke">
<table align="center">
<tr><td align="right">
</table>
<fieldset>
<table>
11
<tr><td align="right"><label>FIRST NAME :</label></td><td><input type="text"
name="fname"/></td></tr>
</table>
</fieldset>
</form>
<%!
Connection conn;
Statement st1,st2;
ResultSet rt;
String fn,ln,us,ps,rp;
int r;
%>
<%
try
fn=request.getParameter("fname");
ln=request.getParameter("lname");
us=request.getParameter("username");
ps=request.getParameter("password");
rp=request.getParameter("rp");
12
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st1=conn.createStatement();
st2=conn.createStatement();
if(!rt.next())
if(ps.equals(rp))
+ps+"','"+rp+"','s')");
else
if(r!=0)
%>
<%
}catch(Exception e){}
%>
13
</body></html>
Due
to
time
constraints,
the
search
bar
at
the
top-‐right
hand
corner
of
the
screen
was
the
preliminary
implementations
of
some
of
the
future
scopes
for
this
project
as
will
be
discussed
further
in
section
4.2.
<html>
<head>
</head>
<body bgcolor="WhiteSmoke">
<table align="center">
14
<tr><td
align="right">
</table>
<table align="right">
</table><br/><br/><br/>
<fieldset>
<legend><b>TOPICS</b></legend>
<ul>
<%!
Connection con;
Statement st;
ResultSet rs;
int tid;
String u,p,student,admin,tnm;
%>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
while(rs.next())
{
tid=rs.getInt(1);
tnm=rs.getString(2);
15
%>
<li><h2><a href="1.jsp">
<%=tnm%></a></h2></li>
<%
}
}catch(Exception e){}
%>
</ul>
</fieldset>
</body>
</html>
16
‘Java as OOPs’ snapshot:
17
‘MCQ’ snapshot:
18
Navigation of topics code:
<html>
<head>
<title></title>
</head>
<body bgcolor="WhiteSmoke">
<table align="center">
<tr><td align="right">
</table>
<fieldset>
<%!
Connection con;
Statement st,st1;
19
ResultSet rs2,rs1,rs3,rs4,rs5;
String id,Question,Info,question1,opt[],a,nm;
int tid,quesnum,count=0,k=0,m=0,i;
%>
<%
try
tid=Integer.parseInt(session.getAttribute("tid").toString());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
st1=con.createStatement();
if(rs1.next())
%>
<legend><b><em><%=rs1.getString(2)%></em></b></legend>
<%
if(tid!=6)
while(rs2.next())
Question=rs2.getString(3);
Info=rs2.getString(4);
%>
20
<table>
<tr><td>
<strong><%=Question%></strong></td></tr>
<tr><td><p id="ans">
<font><%=Info%></font>
</p></td></tr>
</table>
<%
else
//tid=Integer.parseInt(session.getAttribute("tid").toString());
rs3.next();
quesnum=rs3.getInt(2);
question1=rs3.getString(3);
%>
<table>
<tr>
<%=quesnum%>
<%=question1%></tr>
<tr><td>
</p></td></tr>
</table>
<%
21
if(request.getParameter("ak").equals("Next"))
//tid=Integer.parseInt(session.getAttribute("tid").toString());
rs3.next();
}catch(Exception e){}
%>
</fieldset></form></body></html>
22
Admin homepage JSP code:
<html>
<head>
<title>HOME PAGE</title>
</head>
<body bgcolor="WhiteSmoke">
<table align="center">
<tr><td align="right">
</table>
<table align="right">
<tr><td><label><h2>Search:</h2></label></td><td><textarea rows="1"
cols="40"></textarea></tr></td>
</table><br/><br/><br/>
<fieldset>
<legend><b>TOPICS</b></legend>
<ul>
<%!
Connection con;
Statement st;
ResultSet rs;
int tid;
String tnm;
%>
<%
try
{
23
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
while(rs.next())
tid=rs.getInt(1);
tnm=rs.getString(2);
%>
<li><h2><a href="1.jsp?id=<%=tid%>">
<%=tnm%></a></h2></li>
<%
%>
</ul>
</fieldset>
<tr>
</tr>
</table>
<%
/*
if(request.getParameter("update").equals("UPDATE"))
24
{
response.sendRedirect("update.jsp");
else if(request.getParameter("delete").equals("DELETE"))
}*/
}catch(Exception e){}
%>
</body> </html>
Insert.jsp snapshot:
25
After successfully inserting a topic name:
After refreshing the page, we can see the topic name inserted in the database (on the web):
26
Upon entering an invalid entry in the text area:
Insert.jsp code:
<html>
<head><title>Inserting_data_page</title>
</head>
<body>
<table align="center">
<tr>
</tr>
<tr>
</table>
</form>
<%!
Connection con;
int a, x, b;
%>
<tr>
<th>Topic_ID</th><th>Topic_Name</th>
</tr>
<%
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
st1=con.createStatement();
st2=con.createStatement();
st3=con.createStatement();
b=1;
if(b==1 || b==2) {
while(rs.next()) {
%>
28
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
<%
%>
</table>
<%
if(request.getParameter("insert").equals("Insert!"))
tpcNme = request.getParameter("tn");
if(tpcNme.length()!=0) {
empty="";
if(!rs2.next()) {
//
//y = rs2.getString(tpcNme);
if(rs1.next()) {
x = rs1.getInt(1);
x++;
else{
x=1;
b=2;
rs.next();
%>
<%
else {
out.println(empty);
}catch(Exception e){}
%>
</body>
</html>
30
3.4.2 Admin privilege: Update
In this section, we attempted to provide the second privilege that an administrator would attain, in the
form of updating the existing topics within the user/admin homepages, by clicking on the ‘update’
hyperlink.
Update.jsp snapshot:
31
Update.jsp code:
<%!
Connection con;
Statement st;
ResultSet rs;
String tpcNme;
int tid;
%>
<tr>
<th>Topic_ID</th><th>Topic_Name</th>
</tr>
<%
try
tpcNme = request.getParameter("tn");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
st=con.createStatement();
while(rs.next()) {
tid=rs.getInt(1);
%>
<tr>
32
<td><a href="update2.jsp?id=<%=tid%>"><%=tid%></a></td>
<td><%=rs.getString(2)%></td>
</tr>
<%
%>
</table>
<%
if(a>0)
%>
<h1>Record updated!</h1>
<%
}catch(Exception e){}
%>
</body>
</html>
After filling in the same details as mentioned in section 3.2, there would be three events that would take place at the
time of clicking the submission button in the pop-out window.
33
1) The Login table would have to be updated with the contact information of the new user.
2) The existing log-in page should be refreshed, thus allowing for new username/password combinations to be
accepted for access to the database.
3) The pop-out window should close, shifting the focus not to a new login page, but to the existing page that
was already open and running in the background.
Essentially, aesthetically it appears that the search bar has already been implemented in the project, however with a
critical lack in functionality, as administrators, we did not anticipate the complexity in handing the code of such a
feature. However, as a future scope for this project, we believe that the ‘search bar’ would definitely distinguish itself
as a standout feature for this project.
4.4 MCQ.
Upon looking at the snapshot of the MCQ section, we were intending for this to be the dynamic section for the
student user. By testing his/her knowledge with MCQ style questions that would tally up a total mark the student
would achieve, depending on the options selected.
The dynamic component comes from the fact that there would be a checking of the options selected at the time of
submitting the MCQ form, with the MCQ table in the database. Furthermore, at the time of displaying the student’s
result, we would have liked to show the questions and their respective answers, that the student attempted
incorrectly. Thereby, establishing a deeper connection with the user and encourage him/her to either re-attempt the
questions or dig further into understanding the J2SE technology.
34
Chapter 5: Conclusion.
The aim of the project: ‘Java online documentation’, was to explore two of the most important concepts, JSP and
JDBC (through MS-Access), in the powerful technology J2EE. We were able to create dynamic webpages, by
implementing the ideal framework of JSP, which allows for html code and java code to be embedded and
compliment one another.
While the client side of the project was handled by JSP, the server-side connection that the JDBC API was
responsible for was achieved by using the MS-Access software. Creation of an entire database, split into logical and
appropriate tables that correspond to different sections of project, made handling the enormous amount of data
simple and easy to follow, when returning to the project.
The project was essentially broken down in to 3 parts. First, by creating an authentication page, where the user
would have to log into the system in order to access the project’s database, with the option for the creation of a new
user available as well. Secondly, upon successfully logging in, the student now has access to select topics chosen
from the J2SE technology. Depending on what the user wishes to accomplish, either gain succinct knowledge in the
form of immediate questions and answers corresponding to the topics listed or test oneself with the MCQ section.
Thirdly, as admins, we grant further privileges to ourselves by allowing the manipulation of data, specifically to the
user/admin homepages (due to time constraints), through inserting and updating the database.
Finally, due to the ambitious nature of this novel project and severe time constraints, we have outlined our vision in
Chapter 4: what we hope would have made this a solid and distinguished project, fully encapsulating the power and
exploiting the capabilities within the J2EE framework, in order to make it a rich and personal experience for the user
when seeking to gain an insight into J2SE.
As founders of this project, we take great pride in the way we have implemented classroom techniques in learning
and understanding how to design, implement, debug and execute an advanced Java project. The unique and
ambitious nature for our first major project has been an incredibly rewarding experience, but most importantly, it has
given us a tremendous boost in confidence in coding and forced us to constantly think of ways to improve our design
and code. We hope to continue this momentum for more exciting projects to be conducted in the near future.
Chapter 6: References.
[1] Brainware Research Team., (2011) Mastering Advanced Java, Brainware Consultancy Private Limited.
[2] Brainware Research Team., (2007) Mastering Java, Brainware Consultancy Private Limited.
[3] Keogh J., (2002) J2EE: The Complete reference, McGraw Hill Education (India) Private Limited.
[4] Brainware Research Team., (2011) Microsoft Access, Brainware Consultancy Private Limited.
35