Sei sulla pagina 1di 24

ignoubcamcaassignmentsolutions.blogspot.

com

Course Code : BCSL-057


Course Title : Web Programming Lab
Assignment Number : BCA(5)/057/Assignment/2019-20
Maximum Marks : 50
Weightage : 25%
Last Dates for Submission : 15th October, 2019 (For July 2019 Session)
: 15th April, 2020 (For January 2020
Session)
This assignment has one question of 40 marks. Rest 10 marks are for viva
voce. Please go through the guidelines regarding assignments given in the
programme guide for the format of presentation.

Q1.
Create a website for a Bank which offers online Banking service to its registered
customers. The website should be designed using logical divisions through
<div> tags and an external CSS file. Every page of the website is divided into
four divisions namely – Main, Cpyrt, Options and Data as displayed in the
following figure:

Perform the following tasks for the website as given above:


[ Part (a) : 10 Marks + Part (b) : 05 Marks + Part (c) : 05 Marks + Part (d)
: 20 Marks]

(a) Create four pages for the website viz Home, Account Balance, Transactions
and Feedback; all the four pages should have same Main, Options and Cpyrt
division but different Data division. The Options Division should provide links
to the Home page as well as all the other three pages. All these four options
should be available in all the web pages designed by you for this assignment.
Thus, this Option division may be used for navigating among the four web
pages. The Data Division of every page should be different. The information
that should be displayed in Data Division of each of the pages is described
below:
(i) The Home page should display the list of services available through these
pages.
(ii) The Account Balance page should display a form for logging into the
Database of the Bank.
(iii)The Transactions page should display the transactions of the account for
which Balance has been shown.
(iv) The Feedback page should display another form having a text area field for
writing the Feedback and a Button to submit the form.

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

(b) Create an external CSS that gives different background colour to each
division. You may choose the format of other elements as per your choice.

(c) Create a JavaScript program that generates an error message if Username


field is left blank in the form for Account Balance page; or if the length of
entered password in the password field is less than 4 characters . After
displaying the error message, the login form should be displayed again.

(d) Implement the following using jsp program, servlets, java classes,
database(s), etc. for the pages as described below:
(i) When a user presses Submit button after properly filling Username and
password in the form in the Account Balance page, these details are checked in
a database and in case such username and password are correct, the account
number, account holder name and balance of the account are displayed on the
screen. You may also create a cookie, if needed, to remember the account
number for the given username and password (assuming each user has only one
account).
(ii) On selection of Transactions option, all the transactions made (assume only
Deposit and Withdrawal transaction) for the account number, as remembered in
part (d)(i) above, is displayed in a tabular format.
(iii) When you press the Submit button of the Feedback Form, the information
(account number from the cookie and entered text) should be stored in the
database.
(iv) You must design a suitable database structure.

You may make suitable assumptions, if needed.

Ans:-

Home.html
<!DOCTYPE html>

<html>

<head>

<title>BCS053 Assignment Solution</title>

<link rel="stylesheet" type="text/css"


href="externalCSS.css">

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

</head>

<body>

<div id="main">

<img src="logo.jpg" height="100" width="100">

<p> Online Banking </p>

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="option">

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="data">

<p>

Hi There!<br>

Bank provide you following facility...<br>

<ul type="disc">

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

<li>Deposit</li>

<li>Withdrawal</li>

</ul>

</p>

</div>

<div id="crypt">

<p>&copy; Online Banking is Copyright of this


Bank</p>

</div>

</body>

</html>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

AccountBalance.jsp
<%@page contentType="text/html" pageEncoding="UTF-
8"%>

<%@page import="java.util.*, java.sql.*" %>

<!DOCTYPE html>

<html>

<head>

<title>BCS053 Assignment Solution</title>

<link rel="stylesheet" type="text/css"


href="externalCSS.css">
<script type="text/javascript"
src=”externalJavaScript.js”>

</script>

</head>

<body>

<div id="main">

<img src="logo.jpg" height="100" width="100">

<p> Online Banking </p>

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

<div id="option">

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="data">

<form method="GET" action="accBal.jsp">

<p>

Username : <input type="text" name="username"


id="uname"><br>

Password : <input type="password" name="password"


id="pass"><br>
<input type="submit" value="SUBMIT" onclick="return
validate()">

</p>

</form>

<p>

<%

String Name = "" ;

String uname=request.getParameter("username") ;

String pwd=request.getParameter("password") ;

float bal=0 ;

boolean bln= false ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

Connection con =null ;

Statement stmt = null ;

ResultSet rs = null ;

try{

Class.forName("com.mysql.jdbc.Driver") ;

con=DriverManager.getConnection("jdbc:mysql://localho
st:8080/bcsl057","","") ;

if(con!=null){

stmt=con.createStatement() ;
rs=stmt.executeQuery("select * from accInfo where
accNo=" + uname + ";") ;

while(rs.next()){

if(rs.getString("Password").equals(pwd)){

bln=true ;

Name=rs.getString("Name") ;

bal=rs.getFloat("bal") ;

break ;

else{

continue ;

if(bln==true){

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

out.println("Welcome " + Name + "...");

out.println("Account No. :\t"+uname) ;

out.println("Balance :\t"+bal) ;

Cookie cookie = new Cookie("accNo",uname);

cookie.setMaxAge(60*60*60);

response.addCookie(cookie);

else{

out.println("Username or Password is incorrect") ;

rs.close( );

stmt.close() ;

con.close() ;

if(con==null){

con.close() ;

catch(SQLException sqle){

out.println( sqle.getMessage() ) ;

%>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

</p>

</div>

<div id="crypt">

<p>&copy; Online Banking is Copyright of this


Bank</p>

</div>

</body>

</html>

Transaction.jsp
<%@page contentType="text/html" pageEncoding="UTF-
8"%>

<%@page import="java.util.*, java.sql.*" %>

<!DOCTYPE html>

<html>

<head>

<title>BCS053 Assignment Solution</title>

<link rel="stylesheet" type="text/css"


href="externalCSS.css">

</head>

<body>

<div id="main">

<img src="logo.jpg" height="100" width="100">

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

<p> Online Banking </p>

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="option">

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="data">

<p>

<table border="1" >

<tr>

<th>Date</th>

<th>Deposit</th>

<th>Withdrawal</th>

</tr>

<%

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

String accNo = "" ;

Boolean check = false ;

Cookie[] cookies = request.getCookies() ;

for(int i=0; i<cookies.length; i++){

if(cookies[i].getName().equals("accNo")){

accNo = cookies[i].getValue() ;

check = true ;

break ;

if(check){

Connection con =null ;

Statement stmt = null ;

ResultSet rs = null ;

try{

Class.forName("com.mysql.jdbc.Driver") ;

con=DriverManager.getConnection("jdbc:mysql://localho
st:8080/bcsl057","","") ;

if(con!=null){

stmt=con.createStatement() ;

rs=stmt.executeQuery("select * from transactions


where accNo=" + accNo + ";") ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

while(rs.next()){

%>

<tr>

<td><%=rs.getDate("Date")%></td>

<% if(rs.getString("info").equals("d")){ %>

<td><%=rs.getString("Amt")%></td>

<td><%=rs.getString("-")%></td>

<%}

else if(rs.getString("info").equals("w")){ %>

<td><%=rs.getString("-")%></td>

<td><%=rs.getString("Amt")%></td>

<%}

else{ %>

<td><%=rs.getString("-")%></td>

<td><%=rs.getString("-")%></td>

<% } %>

</tr>

<%

rs.close( );

stmt.close() ;

con.close() ;

if(con==null){

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

con.close() ;

out.println("Connection error!") ;

catch(SQLException sqle){

out.println( sqle.getMessage() ) ;

}//end-if-check

else{

out.println("Please login first!") ;

%>

</table>

</p>

</div>

<div id="crypt">

<p>&copy; Online Banking is Copyright of this


Bank</p>

</div>

</body>

</html>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

Feedback.jsp
<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-
8"%>

<%@page import="java.util.*, java.sql.*" %>

<!DOCTYPE html>

<html>

<head>

<title>BCS053 Assignment Solution</title>

<link rel="stylesheet" type="text/css"


href="externalCSS.css">

<script type="text/javascript">

function validate(){

if(document.getElementById("fdbk").value == ""){

alert("Enter feedback please!!!") ;

return false ;

else

return true ;

</script>

</head>

<body>

<div id="main">

<img src="logo.jpg" height="100" width="100">

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

<p> Online Banking </p>

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="option">

<ul>

<li><a href="home.html">Home</a></li>

<li><a href="accBal.jsp">Account Balance</a></li>

<li><a href="transact.jsp">Transactions</a></li>

<li><a href="feedback.jsp">Feedback</a></li>

</ul>

</div>

<div id="data">

<form method="GET" action="feedback.jsp">

<p>

Feedback : <textarea name="feed"


id="fdbk"></textarea><br>

<input type="submit" value="SUBMIT" onclick="return


validate()">

</p>

</form>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

<p>

<%

String accNo = "" ;

Boolean goAhead = false ;

String msg = "" ;

Cookie[] cookies = request.getCookies() ;

for(int i=0; i<cookies.length; i++){

if(cookies[i].getName().equals("accNo")){

accNo = cookies[i].getValue() ;

goAhead = true ;

break ;

if(goAhead){

if(request.getAttribute("feed") == null ){

msg = "To give feedback, you must be logged in!"


;

else{

String fdbk=request.getParameter("feed") ;

java.util.Date date = new java.util.Date() ;

SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-


dd") ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

Connection con =null ;

Statement stmt = null ;

try{

Class.forName("com.mysql.jdbc.Driver") ;

con=DriverManager.getConnection("jdbc:mysql://localho
st:8080/bcsl057","","") ;

if(con!=null){

stmt=con.createStatement() ;

stmt.executeUpdate("insert into feedback values('"+


accNo +"','"+ fdbk +"','"+ dt.format(date)+"') ;") ;

stmt.close() ;

con.close() ;

if(con==null){

msg = "Connection not established...try again later!"


;

catch(SQLException sqle){

msg = "Some error occured while processing!" ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

else{

msg = "Login to give feedback!" ;

out.println(msg) ;

%>

</p>

</div>

<div id="crypt">

<p>&copy; Online Banking is Copyright of this


Bank</p>

</div>

</body>

</html>

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

externalCSS.css
#main{

left: 0 ;

top: 0 ;

position: fixed ;

height: 150px ;

width: 100% ;

font: 25px'century gothic' ;

background-color: #f1f1f1 ;

#main img{

position: absolute ;

margin-left: 20px ;

margin-top: 10px ;

#main p{

text-align: center ;

#main ul{

list-style-type: none ;

margin-top: 50px ;

#main ul li{

display: inline ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

margin-left: 100px ;

margin-right: 50px ;

#option{

left: 0 ;

top: 150px ;

position: fixed ;

width: 20% ;

height: 100% ;

font: 25px'century gothic' ;

background-color: #e1e1e1 ;

overflow-y: scroll ;

#option ul{

list-style-type: none ;

margin-top: 100px ;

#option ul li{

display: block ;

margin: 20px 5px ;

#crypt{

bottom: 0 ;

left: 0 ;

position: fixed ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

width: 100% ;

background-color: #f1f1f1 ;

#crypt p{

margin-left: 40% ;

font: 15px 'cambria math' ;

#data{

right: 0 ;

top: 150px ;

position: absolute ;

z-index: -1 ;

height: 100% ;

width: 80% ;

background-color: #c1c1c1 ;

overflow-y: scroll ;

#data p{

margin: 20px 10px 20px 40px ;

font: 20px 'century gothic' ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

externalJavaScript.js
function validate(){

if(document.getElementById("uname").value == ""){

alert("Enter username!!!") ;

return false ;

else if(document.getElementById("pass").value == ""){

alert("Enter password!!!") ;

return false ;

else if(document.getElementById("pass").value.length
< 4){

alert("Invalid password!!!") ;

return false ;

else

return true ;

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

Output Screens

Home.html

AccountBalance.jsp

ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com

Transactions.jsp

Feedback.jsp

ignoubcamcaassignmentsolutions.blogspot.com

Potrebbero piacerti anche