Monday, February 28, 2011

Book Bank System

PROBLEM STATEMENT:
Book bank system is where the books can be collected every semester and must be returned at the end of semester. The system must have option for new members to enroll for membership by paying deposit. A provision for getting six or seven books per semester. Membership can be renewed by using the register number. The deposit must be refunded on termination of membership. A database must be maintained to guide the issuer to track the details of students. Search option must be provided so that the member can search for the availability of a particular book.

SOFTWARE REQUIREMENT SPECIFICATION
TABLE OF CONTENTS
1.         1  Introduction
1.1  Purpose
1.2  Product scope
1.3  Document conventions
1.4  References
2.         2 Overall Description
2.1  Product Perspective
2.2  Product Functions
2.3  Tools to be used
  1. External Interface
3.1  Hardware Interface
3.2  Software Interface
  1. System Features
4.1  Requesting Books
4.1.1        System Description and Priority
4.1.2        Stimulus/response Sequence
4.1.3        Functional Requirements
  1. Other non-functional requirements
5.1   Performance Requirements
5.2   Safety Requirements
5.3   Security Requirements
   

1. INTRODUCTION
The book bank is a set up that lends books for all its members which they can return at the end of each semester. It has a huge collection of books and has to keep track of all its members’ details such as requests, dues and penalties and the books.
1.1 PURPOSE
The purpose of this document is to present a detailed description of the Book Bank System. It will explain the purpose and features of the system, the interfaces of the system, what the system will do, the constraints under which it must operate and how the system will react to external stimuli.   
1.2   SCOPE
The book bank holds an online interface with its members for maintaining all kinds of transaction details. Each member is provided with a unique user id at the time of registering as a member.
1.3   DOCUMENT CONVENTIONS
·         Director: The ultimate authority in the staff hierarchy of the book bank
·         Member: Any person who registers with the book bank
·         HTML-Hyper Text Markup Language used to create web page.

1.4    REFERENCES
www.reachbookbank.com
www.bookworldlibrary.com
2. OVERALL DESCRIPTION
2.1 PRODUCT PERSPECTIVE
This project is a self contained one for enabling a book bank organization to be connected with its students, through this system, the students can check for availability of books, makes requests, etc.
2.2 PRODUCT FUNCTIONS
This system functions with a database at the back end, for keeping track of its member’s dues and payments, and also its available resources. Every student who is a member needs only a web browser to connect to this system.
2.3 TOOLS TO BE USED
Visual basic and Microsoft Access
3. EXTERNAL INTERFACES

3.1 HARDWARE INTERFACES
The system should have good hardware support. The processor should have high speed and must be of high efficiency.
3.2 SOFTWARE INTERFACE
               The system uses ODBC drive to connect and control the database.
4. SYSTEM FEATURES
4.1 REQUESTING BOOKS
4.1.1 SYSTEM DESCRIPTION & PRIORITY
Allows a student, who becomes a member to login using a unique id issued at the time of registering as a member, and after logging in, the member can browse through available books and make requests accordingly. The books will be issued provided there is no due, regarding returning of previous books.
4.1.2 STIMULUS/RESPONSE SEQUENCE
Whenever the student wishes to get books, he/she checks for the availability by logging in. When the request is made, the director of the book bank decides on granting the request of book(s) after checking the member details for due in returning previous books.
4.1.3 FUNCTIONAL REQUIREMENTS
The member should be authenticated by means of unique login id and password. The availability of books requested must be prompted to the user through e-mail or sms notifications. 
5. OTHER NON-FUNCTIONAL REQUIREMENTS
5.1 PERFORMANCE REQUIREMENTS
The web interface should be able to support multiple users trying to log in simultaneously.
5.2 SAFETY REQUIREMENTS
The student details should be made available in the database and must be updated every time a book is issued or returned or some kind of payment takes place to prevent errors.
5.3 SECURITY REQUIREMENTS
The member can only access certain details from the database. He/she should not be able to modify the database nor has any of its information corrupted. Only the DBA must be bestowed with the privileges of handling any kind of modifications.

Friday, February 25, 2011

Online Eamination using JSP and Databases

 Question - Write programs in Java to create three-tier applications using JSP and Databases for conducting online examination.


Download Source code

Download Database file

index.jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Welcome to Online Examination</title>
    </head>
    <body bgcolor="cyan">
        <form name="index" action="exam.jsp" method="post">
        <center><h1><span><font color="red">Welcome to Online Examination</font></span></h1>
        <br>
        <h2><u><span><font color="blue">Instructions to the Candidates</font></span></u></h2>
        <br><h3><ol><li>Fill the correct Registration number.</li>
        <br><li>Enter your name.</li>
        <br><li>Read the questions carefully.</li>
        <br><li>No negative marking.</li></ol></h3>
     
        <br>
        <b>Enter your Register number</b>
        <input type="text" name="txt_reg">
        <b>Enter your Name</b>
        <input type="text" name="txt_name"><br><br>
        <input name ="submit" value="Submit" type="submit"/>
        </center>
        </form>
    </body>
</html>


exam.jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Examination Panel</title>
    </head>
    <body bgcolor="cyan">
        <%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
String reg= request.getParameter("txt_reg");
String name = request.getParameter("txt_name");
out.println("<h2>Welcome"   name   "...Your Register number is "   reg   "!!</h2><br><br><br>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM "   sTable   "";
String sDBQ = "C:/Users/A/Documents/NetBeansProjects/Online Examination/exam.mdb";

String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="   sDBQ   ";DriverID=22;READONLY=true";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
while(rs.next())
{

out.println("<form name='exam' action='report.jsp' method='post'><b>" i " . "   rs.getString(1)   "</b><br><br>");
s1 = rs.getString(2);
s2 = rs.getString(3);
s3 = rs.getString(4);
s4 = rs.getString(5);
out.println("<input type=radio name=opt" i " value=" s1 " CHECKED>"  s1  " <br><br>");
out.println("<input type=radio name=opt" i " value=" s2 ">"   s2  "<br><br>");
out.println("<input type=radio name=opt" i " value=" s3 ">"   s3  "<br><br>");
out.println("<input type=radio name=opt" i " value=" s4 ">"   s4  "<br><br>");
i  ;
}
out.println("<input name ='submit' value='Submit' type='submit'/>");
/*int n = rsmd.getColumnCount();
out.println( "<table border=1 cellspacing=3><tr>" );
for( int i=1; i<=n; i   ) // Achtung: erste Spalte mit 1 statt 0
out.println( "<th>"   rsmd.getColumnName( i )   "</th>" );
while( rs.next() )
{
out.println( "</tr><tr>" );
for( int i=1; i<=n; i   ) // Achtung: erste Spalte mit 1 statt 0
out.println( "<td nowrap>"   rs.getString( i )   "</td>" );
}
out.println( "</tr></table>" );*/
}
  finally {
try { if( null != rs ) rs.close(); } catch( Exception ex ) {}
try { if( null != st ) st.close(); } catch( Exception ex ) {}
try { if( null != cn ) cn.close(); } catch( Exception ex ) {}
}

%>
       
    </body>
</html>

report.jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Exam Report</title>
    </head>
    <body bgcolor="cyan">
        <center><h1>Your Report Card</h1></center>
 <%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM "   sTable   "";
String sDBQ = "C:/Users/A/Documents/NetBeansProjects/Online Examination/exam.mdb";

String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="   sDBQ   ";DriverID=22;READONLY=true";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
int correct=0,incorrect=0,total=0;
out.println("<h2><br><br><center><table border=1 cellpadding=2 cellspacing=2><tr><th>Question</th><th>Your Answer</th><th>Correct Answer</th><th>Status</th></tr>");
while(rs.next())
{
total  ;
s1 = rs.getString(1);
s2 = request.getParameter("opt" i);
s3 = rs.getString(6);
if(s2.equals(s3))
{
    s4="Correct";
    correct  ;
}
else
{
    s4="Incorrect";
    incorrect  ;
}   
out.println("<tr><td>" s1 "</td><td>" s2 "</td><td>" s3 "</td><td>" s4 "</td></tr>");
i  ;
}
out.println("</table><br><br><table><b><tr><td>Correct Answers</td><td>" correct "</td></tr>");
out.println("<tr><td>Incorrect Answers</td><td>" incorrect "</td></tr>");
out.println("<tr><td>Total Questions</td><td>" total "</td></tr></table></b></center></h2>");

}
  finally {
try { if( null != rs ) rs.close(); } catch( Exception ex ) {}
try { if( null != st ) st.close(); } catch( Exception ex ) {}
try { if( null != cn ) cn.close(); } catch( Exception ex ) {}
}

%>
     
    </body>
</html>





Screenshots


index.jsp


exam.jsp


report.jsp



Hope u like it guys..:)

Wednesday, February 9, 2011

Passport Automation System UML Diagrams



Use case Diagram


Class Diagram


Sequence Diagram


New Registration


Check Status

Admin Panel


Activity Diagram


New Registration







Check Status


Admin Panel




Collaboration Diagrams

New Registration


Check Status

Admin Panel



Guys, I have attached most of the UML Diagrams for Passport Automation System..

Hope you like it..

Wishing you good Luck..:)

Disclaimer - The UML diagrams given might have some mistakes..So please take care when you use it and please do comment about any mistakes you find so that we can rectify it.

Monday, February 7, 2011

Invoking servlets from HTML forms

Question - "To invoke servlets from HTML forms".

To work on this program, I recommend you to download Netbeans IDE.

You can download Netbeans IDE from the following link,

http://netbeans.org/downloads/

After you download and install perform the following procedure,

Procedure to run this program on Netbeans
  • Start Netbeans IDE.
  • Now Select File->New Project.
  • In the New Project Dialog box that appears  select Java Web(Web Application).
  • Now “New Web Application” Dialog box appears.
  • Give the Project Name as “ServletApplication”.
  • Click Next twice and then Finish.
  • Now a web application named ServletApplication is created with a default page “index.jsp”. There write the code for HTML forms.
  • Then right click on the WEB-INF folder and select New-> Servlet. Give the name of the servlet as “MyServlet” , click Next. In the next dialog that appears please make sure “Add information to deployment descriptor” checkbox is selected. Now click next and then finish.
  • Write the code for Servlet in it.
  • To compile the file, right click on index.jsp and then select “compile file”.
  • After compiling, again right click on index.jsp and select “Run file”.
  • Now the browser(use firefox) will open and verify the output.
Download the Source code 


Code

index.jsp

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
    <head><title>HTML Forms and Servlet</title></head>
    <body>
        <%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
        <%-- <jsp:getProperty name="beanInstanceName"  property="propertyName" /> --%>
        <h1>Enter your Details</h1>
        <form action = "MyServlet">
        <table>
        <tr>
        <td>Name
        <td><input type="text" name="name"><br><br>
        </tr>
        <tr>
        <td>Reg No
        <td><input type="text" name="reg"><br><br>
        </tr>
        <tr>
        <td>Sub1 Mark
        <td><input type="text" name="sub1"><br><br>
        </tr>
        <tr>
        <td>Sub2 Mark
        <td><input type="text" name="sub2"><br><br>
        </tr>
        <tr>
        <td>Sub3 Mark
        <td><input type="text" name="sub3"><br><br>
        </tr>
        <tr>
        <td>Sub4 Mark
        <td><input type="text" name="sub4"><br><br>
        </tr>
        <tr>
        <td>Sub5 Mark
        <td><input type="text" name="sub5"><br><br>
        </tr>
        <tr>
        <td>Sub6 Mark
        <td><input type="text" name="sub6"><br><br>
        </tr>
        </table>
        <input type="submit">
        </form>
    </body>
</html>


MyServlet.java

/*
 * MyServlet.java
 *
 * Created on February 3, 2011, 9:03 PM
 */
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author  Administrator
 * @version
 */
public class MyServlet extends HttpServlet {
    /** Initializes the servlet.
     */
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    /** Destroys the servlet.
     */
    public void destroy() {

    }
      public String display(int mark)
    {
        if(mark>90 && mark<=100)
    {
    return "S";
    }
    else if(mark>80 && mark<=90)
    {
    return("A");
    }
    else if(mark>70 && mark<=80)
    {
    return("B");
    }
    else if(mark>60 && mark<=70)
    {
    return("C");
    }
    else if(mark>55 && mark<=60)
    {
    return("D");
    }
    else if(mark>=50 && mark<55)
    {
    return("E");
    }
    else
    {
    return("Re Appear");
    }
    }
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     */

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        try {
            String name, reg;
            int mark,s1,s2,s3,s4,s5,s6;
name = request.getParameter("name");
reg = request.getParameter("reg");
s1 = Integer.parseInt(request.getParameter("sub1"));
s2 = Integer.parseInt(request.getParameter("sub2"));
s3 = Integer.parseInt(request.getParameter("sub3"));
s4 = Integer.parseInt(request.getParameter("sub4"));
s5 = Integer.parseInt(request.getParameter("sub5"));
s6 = Integer.parseInt(request.getParameter("sub6"));

response.setContentType("text/html");

out.println("<html>");
out.println("<head>");
out.println("<title>Mark Report Servlet<title>");
out.println("</head>");

out.println("<body>");
out.println("<center><p><h2><b>Name :" + name + "</p>");
out.println("<p><b>Reg No :" + reg + "</p>");
out.println("<p><b>Your Mark Details</p><br><br></center>");
out.println("<center><table border=2 cellpadding=5 cellspacing=5>");
out.println("<tr><th>Subjects</th><th>Mark</th><th>Grade</th></tr>");
out.println("<tr><th>Sub1</th><td>"+s1 + "</td><td>" + display(s1) + "</td></tr>");
out.println("<tr><th>Sub2</th><td>"+s2 + "</td><td>"  + display(s2) + "</td></tr>");
out.println("<tr><th>Sub3</th><td>"+s3 + "</td><td>"  + display(s3) + "</td></tr>");
out.println("<tr><th>Sub4</th><td>"+s4 + "</td><td>"  + display(s4) + "</td></tr>");
out.println("<tr><th>Sub5</th><td>"+s5 + "</td><td>"  + display(s5) + "</td></tr>");
out.println("<tr><th>Sub6</th><td>"+s6 + "</td><td>"  + display(s6) + "</td></tr></table>");
out.println("</body>");
out.println("</html>");
        } finally {
            out.close();
        }

    }

    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }

Note

Some parts of the code will be automatically generated by Netbeans itself. So you need not worry.

Screenshots




Thursday, February 3, 2011

Reg: OOAD Lab Experiments

For all those who been mailing me for the past one month regarding the OOAD Lab exercises, I couldn't complete my work on  it and it would take some more time to upload the use case diagrams and other stuffs.

I regret for the inconvenience caused by the delay.

Stay tuned for updates.

With Regards,
G.Vivek Venkatesh