Beruflich Dokumente
Kultur Dokumente
com
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:
(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.
(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.
Ans:-
Home.html
<!DOCTYPE html>
<html>
<head>
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
</head>
<body>
<div id="main">
<ul>
<li><a href="home.html">Home</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="transact.jsp">Transactions</a></li>
<li><a href="feedback.jsp">Feedback</a></li>
</ul>
</div>
<div id="data">
<p>
Hi There!<br>
<ul type="disc">
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
<li>Deposit</li>
<li>Withdrawal</li>
</ul>
</p>
</div>
<div id="crypt">
</div>
</body>
</html>
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
AccountBalance.jsp
<%@page contentType="text/html" pageEncoding="UTF-
8"%>
<!DOCTYPE html>
<html>
<head>
</script>
</head>
<body>
<div id="main">
<ul>
<li><a href="home.html">Home</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="transact.jsp">Transactions</a></li>
<li><a href="feedback.jsp">Feedback</a></li>
</ul>
</div>
<div id="data">
<p>
</p>
</form>
<p>
<%
String uname=request.getParameter("username") ;
String pwd=request.getParameter("password") ;
float bal=0 ;
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
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("Balance :\t"+bal) ;
cookie.setMaxAge(60*60*60);
response.addCookie(cookie);
else{
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">
</div>
</body>
</html>
Transaction.jsp
<%@page contentType="text/html" pageEncoding="UTF-
8"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="main">
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
<ul>
<li><a href="home.html">Home</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="transact.jsp">Transactions</a></li>
<li><a href="feedback.jsp">Feedback</a></li>
</ul>
</div>
<div id="data">
<p>
<tr>
<th>Date</th>
<th>Deposit</th>
<th>Withdrawal</th>
</tr>
<%
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
if(cookies[i].getName().equals("accNo")){
accNo = cookies[i].getValue() ;
check = true ;
break ;
if(check){
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() ;
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
while(rs.next()){
%>
<tr>
<td><%=rs.getDate("Date")%></td>
<td><%=rs.getString("Amt")%></td>
<td><%=rs.getString("-")%></td>
<%}
<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{
%>
</table>
</p>
</div>
<div id="crypt">
</div>
</body>
</html>
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
Feedback.jsp
<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-
8"%>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function validate(){
if(document.getElementById("fdbk").value == ""){
return false ;
else
return true ;
</script>
</head>
<body>
<div id="main">
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
<ul>
<li><a href="home.html">Home</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="transact.jsp">Transactions</a></li>
<li><a href="feedback.jsp">Feedback</a></li>
</ul>
</div>
<div id="data">
<p>
</p>
</form>
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
<p>
<%
if(cookies[i].getName().equals("accNo")){
accNo = cookies[i].getValue() ;
goAhead = true ;
break ;
if(goAhead){
if(request.getAttribute("feed") == null ){
else{
String fdbk=request.getParameter("feed") ;
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
try{
Class.forName("com.mysql.jdbc.Driver") ;
con=DriverManager.getConnection("jdbc:mysql://localho
st:8080/bcsl057","","") ;
if(con!=null){
stmt=con.createStatement() ;
stmt.close() ;
con.close() ;
if(con==null){
catch(SQLException sqle){
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
else{
out.println(msg) ;
%>
</p>
</div>
<div id="crypt">
</div>
</body>
</html>
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
externalCSS.css
#main{
left: 0 ;
top: 0 ;
position: fixed ;
height: 150px ;
width: 100% ;
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% ;
background-color: #e1e1e1 ;
overflow-y: scroll ;
#option ul{
list-style-type: none ;
margin-top: 100px ;
#option ul li{
display: block ;
#crypt{
bottom: 0 ;
left: 0 ;
position: fixed ;
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
width: 100% ;
background-color: #f1f1f1 ;
#crypt p{
margin-left: 40% ;
#data{
right: 0 ;
top: 150px ;
position: absolute ;
z-index: -1 ;
height: 100% ;
width: 80% ;
background-color: #c1c1c1 ;
overflow-y: scroll ;
#data p{
ignoubcamcaassignmentsolutions.blogspot.com
ignoubcamcaassignmentsolutions.blogspot.com
externalJavaScript.js
function validate(){
if(document.getElementById("uname").value == ""){
alert("Enter username!!!") ;
return false ;
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