Real-Time Finance Management System
Real-Time Finance Management System
CSUSB ScholarWorks
2006
Recommended Citation
Muqtadir, Abdul, "Real-time finance management system" (2006). Theses Digitization Project. 2992.
https://scholarworks.lib.csusb.edu/etd-project/2992
This Project is brought to you for free and open access by the John M. Pfau Library at CSUSB ScholarWorks. It has
been accepted for inclusion in Theses Digitization Project by an authorized administrator of CSUSB ScholarWorks.
For more information, please contact scholarworks@csusb.edu.
REAL-TIME FINANCE MANAGEMENT SYSTEM
A Project
Presented to the
Faculty of
San Bernardino
In Partial Fulfillment
Master of Science
in
Computer Science
by
Abdul Muqtadir.
March 2006
REAL-TIME FINANCE MANAGEMENT SYSTEM
A Project
Presented to the
Faculty of
San Bernardino
by
Abdul Muqtadir
March 2006
date
their finances.
perspective.
iii
ACKNOWLEDGMENTS
given me.
iv
TABLE OF CONTENTS
ACKNOWLEDGMENTS ................................ iv
vi
4.2 Maintenance Guidelines ............. 25
REFERENCES ....................................... 78
vii
LIST OF FIGURES
viii
CHAPTER ONE
1.1 Introduction
their finances.
a clear perspective.
1
format which is taken by the Java program and displayed
finances.
2
is done for stand-alone systems where■the users usually
computer.
in the system.
Calculations.
3
*
5
' tools. It adds interactive functions to HTML
6
Model (DOM) and Simple API for XML (SAX) and uses
7
Wide Web Consortium (W3C) standard for
W3C.
remove it).
well.
8
CHAPTER TWO
SOFTWARE DESIGN
2.1 Introduction
9
5. Difficulty in analyzing information from budget
the issues.
of 2 types:
• System Administrator
• User
figures:
10
Administrator
$Expenditure Analysis
lorT)
Account Information
i-
11
2.3 Detailed Design
high scalability.
13
A. Client Tier: The Java enabled web browsers are
system.
language used by RFMS was Java and its JSP technology. JSP
14
However, JSP is Java-based, whereas ASP is Visual
Though JSP pages may have Java interspersed with HTML, all
presentation.
15
independent. This means that JSP pages can be
server.
Pages.
possible by J2EE.
extensible.
1. Stocklnfo
2 . Users
3 . UsersAdmin
4. TimeAndSales
5 . TopList
16
6. DateBean
7 . Reminder
8. DebtPlanner
9 . Expenditure
10. Accountlnfo.
steps:
17
it a useful platform for developing and deploying
software.
18
6. Test your web application.
Linux etc. The browsers that the client can use for
3.x or higher.
2.5 Summary
19
CHAPTER THREE
SYSTEM VALIDATION
3.1 Introduction
on the user types since each user has its own set of
20
2. User data input was given to check if the
functionality.
A. Systems Administrator:
21
• Edit user account
B. User
• Manage Portfolio
• Setup Reminders
• Account Information
obtained:
functionality.
22
4. The user functionality was tested for bugs and
values.
balance book.
23
3.4 System Test Plan
were performed:
browser successfully.
24
CHAPTER FOUR
MAINTENANCE
4.1 Introduction
application.
the application.
25
4.2.2 Administration
4. JDBC Driver
5. Macromedia Dreamweaver
called "rfms".
rfms directory
All the . jsp and .html files are saved here. The
26
2. JavaScript Code for user-input validation:
createUserCheck.jsp.
createUserInsert.jsp.
The common files used by all the users are placed directly
under "rfms", but all the other pages are placed in sub
called rfms_modules.
27
CHAPTER FIVE
PROJECT IMPLEMENTATION
5.1 Introduction
These include:
1. Portfolio Management
2. Reminder Setup
4. Expenditure Analysis
5. Account Information
28
5.2 System Interfaces
5.2.1 Login
1. Get Quote
29
t.?»Regl-Tirne4FinBhceiManagernenl.System -Microsoft Interjie^Expbreri . j,
L®'
File Edit View . Favorftes Tools Help - ", _ ...
I
Real-Time Finance Management System
'Portfolio
\ Management s
Get Quote
Reminders
Debt Planning
Choose # ofRecords:
30
^ReabTiipe Fmance.ManagEnientSystem • Portfolio Manage(Ticnl- Microsoft Ihternet Explore# as
31
siSReaJ-Time Finance Manaecmenl Systenv-.Rqrlfolio Management - Microsoft Internet Explores a
Get Quote: |
Top 20 List
RANK SYMBOL MARKET TIME “ MATCHED SHARES
Expenditures
5 8 csco NM ' 17J800 14-58-25.27S-05-O0 15000740 ................. *
32
MReal-Time Finance, Wanagemenl System r Portfolio'Management- Microsoft InlernetExplor.cr,
Fite Edit View Favorites Tools Help , - J
©8«ck -©'00 /Jsearch "^Favorites ^3)1 fg- & w -
Ha
Address litSl htto://kxabost:80e0/rfm5/DortfoEo/oetTimeAndSales.lsp Go
■X
■“
Get Quale: HH|H jjgj!
i » ■
ft
MATCHED
PRICE ,
f TTKTr
-miE . u
MATCH
nTE
*
I
REFERENCE
NUMBER
1
|
1
SHARES
14:59:56398-05:00 ■ B J 2121616
t. .100 378.2500
t i ( f i CJ Local Intranet
Dons ■'
call is 100.
33
/iRcahTimft Finance Managemenl'f yslem * yicrp.soft‘Inicrnel Explorer ’ -7— —.... ggg
£
File ' Edit Wew •Favorites Tools Help - c-
©^ ' © 0 ® © :9SM'ch dd0™*'5 ® j I1 ’ ■
•Addrtts4^Ihttp://loca!hosti8080/rfms/reminders/index.htfri : Kl'S 50
’ REMINDERS
Portfolio « . .. ..
Management Setup Wew Reminders
much interest will you pay over the term of the loan or
how much will your loan payments per month will be.
34
70®)®
, ReaUTime Finance Manafiemen^S>5lemi+Micrgsofl Irilernct Explorer
; Address http://localhost:&]80/rfms/debt/index.btm ]
Loan Calculator
Reminders'
the term and the interest rate users could get valuable
monthly expenses every month and then they can use this
that they can better analyze their budget for the upcoming
months.
35
s RcahTime Finance Management System - Microsoft Internet Explorer
EXPENDITURE ANALYSIS
Portfolio
Management Entering budget informationTor each month Will help you analyze yoiir spending
1. Housing (Mortgage/Reht)
4, Auto Insurance.
6, Miscellaneous
transactions.
36
^iRcal-^irnc:Finahco.ManagemcnTSystem - Microsoft Internet Explorer I “
Fite
©esck ’
Edit View
© ’
Favorites
hl
Tools
1*3 © j
Help..- ? j,
'h*’’""*”
, ®
■© i IV ’
«.
• i .®L
Home
ACCOUNT INFORMATION
Portfolio
Management „ Here you can find the: tool to balance your check book,,
Debt Planning
Enter your beginning balance,
Expenditures
|| , EHTfiR TRANSACTION ||
Account
Information Descnphon oEtheTransactiori:
Transaction Type:
Transaction D ate: 1
Amount: IjHHHHHBB
Y... :... —-am.-. ........... 11
37
'.i Real-'flnic^hanco ManagcniBnUSysteniLMicrosofJ'Internet Explorer-
Address http://tocahost:0Oao/rfms/account/vtew8abnceBook.Jsp
ACCOUNT INFORMATION
Portfolio
Management Balance Check Book Details
Account
Information
38
CHAPTER SIX
6.1 Conclusions
the view that the Web already has everything necessary for
like SOAP and UDDI. RFMS used Java and XML to get this
39
data using REST architecture. Part of this data was stored
future.
40
Tools: the more the better. There is no limit on the
principal.
Finally and once again, use XML to send data back and
41
APPENDIX
42
Here is the source code from some of the files used in Real-Time Finance
Management System.
database.java
//java document
package rfms_modules;
import j ava. sql. *;
public class database
{
private static String url="jdbc:mysql://localhost/rfms";
private static String driver="com.mysql.jdbc.Driver";
private static String user="mac";
private static String password="rfms";
43
DateBean.java
// Java Document
package rfms_modules;
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import java.util.*;
44
Stocklnfo.java
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import java.util.*;
import org.apache.xerces.parsers. *;
public StocklnfoO {
marketSession =
matchedShares =
matchPrice = "";
matchTime=
1
45
public static String getMatchTimeO {
return matchTime;
}
try {
String x =
"http://xml.island.com/ws/xml/quote.xml?token=TXHE3PCsMdCGBWd7&sy
mbol="+symbol;
Document d = new SAXBuilderQ.build(x);
46
Element e = new ElementfislandData");
List children = d.getRootElementO.getChildrenO;
//for (Iterator i=children.iterator();i.hasNextO;) {
for (int i=0, size=children.sizeO; i<size;i++) {
//Object child = i.nextO;
Element child = (Element)children.get(i);
/* if (child instanceof Element){
//name +=child.toStringO;
Element e2 = (Element) child;
name += e2.getNameO;
1
*/
name +=child.getNameO;
name +="<br>";
1
Element temp = d.getRootElement().getChild("stock").getChild("matched");
setMarketSession(temp. getAttributefmarketSession")
.getValueO);
setMatchedShares(temp.getChild("matchedShares")
.getValueO);
setMatchPrice(temp.getChild("lastMatch")
. getChildC'matchPrice"). getValueO);
setMatchTime(temp.getChild("lastMatch")
.getChild("matchTime") .getValueO):
1
catch (Exception e) {
e.printStackTraceO;
retumCThere was a exception"+e);
1
return (name);
1
}
TimeAndSales.java
47
// Java Document for timeandsales.xml
package rfms_modules;
48
String str = "There was an exception"+e;
Element error = new Element("ERROR");
error. addContent(str);
Document d = new Document(error);
retum(d);
}
} // end builDocument
} // end class TimeAndSales
49
TopList.java
import java.io.*;
import org.jdom.*;
import org.j dom. input.*;
import org.jdom.output.*;
import java.util.*;
import org.apache.xerces.parsers.*;
50
catch (Exception e) {e.printStackTraceO:
String str = "There was an exception"+e;
Element error = new Element("ERROR");
error. addContent(str);
Document d = new Document(error);
retum(d);
}
} // end builDocument
} // end displayTopList
} // end class TopList
51
loginVerify.jsp
foundRecord = rs.firstO;
if (password.equals(rs.getString("password"))) {
matched = true;
} else {
matched = false;
}
if (foundRecord&&matched) {
52
}
else {
response. sendRedireet("index.jsp?login=0");
}
1
catch(SQLException e){
response. sendRedirect("index.j sp?login=0");
}
%>
53
getTopList.jsp
<html>
<head>
<title>Real-Time Finance Management System - Portfolio Management</title>
cmeta http-equiv="Content-Type" content="text/html; charset=iso-8859-l">
</head>
54
ctable align="center" width="100%">
<tr>
ctd width="14%">
ctable align="left" cellpadding="8" cellspaclng="2" width="100%">
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa
href="../index.html">Home</ax/fontx/strongx/fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif >Portfoliocbr>
Managementc/fontx/strongx/fontx/divx/td>
c/tr>
ctr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif 'xa
href="reminders/index.html">Remindersc/ax/fontx/strongx/fontx/div>
c/td>
c/tr>
ctr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa href="debt/index.html">Debt
Planningc/ax/fontx/strongx/fontx/divx/td>
c/tr>
ctr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif >ca
href="expenditures/index.html">Expendituresc/ax/fontx/strongx/fontx
/divx/td>
c/tr>
ctr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif xa href="account/index.html">Account
55
Information</ax/font></strong></font></div></td>
</tr>
<tr>
<td>
<p> </p>
</td>
</tr>
</table>
<p> </px/td>
ctd width="86%"xtable width='TOO°/o"xtrxtd>
<p align="center">
<form name="forml" method="post" action="getQuote.jsp">
<p align="right"xfont color="#FFFFFF"xstrongxfont size="-l">Get
Quote: </fontx/strongx/font> <font size="-l">
<input name="stockName" type="text" id="stockName" size="10">
cinput type="submit" name="Submit" value="GO">
</font> </p>
</form>
<div align="center">
<pxstrongxfont color="#FF6666" size="6">Top
<%out.print("
out.print(request.getParameter("recNumb"));
out.print(" ");%>
List</fontx/strongx/p>
ctable width="100%" border="2" align="center" cellpadding="2"
cellspacing="2">
<tr>
ctdxdiv allgn="center"xstrongxfont size="-l"> RANK</font>
</strongx/divx/td>
ctdxdiv align="center"xstrongxfont size="-l">
SYMBOLc/fontx/strongx/divx/td>
ctdxdiv align="center"xstrongxfont size="-l">
MARKETc / fontx/strongx/divx/td>
56
ctdxdiv align="center">cstrong>cfont size="-l">
PRICEc/font>c/strong>c/div>c/td>
ctdxdiv align="center"xstrongxfont size="-l">
TIME</fontx/strongx/divx/td>
ctdxdiv align="center"xstrongxfont size="-l">MATCHED SHARES
c/fontx/strongx/divx/td>
c/tr>
c%
Document d = tl.buildDocument(Integer.parseInt(request.getParameter("recNumb")));
Element root = d.getRootElementO;
Element stockList = root.getChild("stockList");
List stocks = stockList. getChildrenO:
for (inti=O, size=stocks.sizeO; icsize;i++) {
Element stock = (Element)stocks.get(i); %>
ctr>
ctdxdiv align="center"xfont size="-l">
c%out.print(stock.getAttribute("rank").getValueO);%x/fontx/divx/td>
ctdxdiv align="center"xfont size="-l">
c%out.print(stock.getAttribute("syrnbol").getValueO);%x/fontx/divx/td>
ctdxdiv align="center"xfont size="-
l"x%out.print(stock.getChild("market").getValueO);%x/fontx/divx/td>
ctdxdiv align="center"xfont size="-
l">c%out.print(stock.getChild("matched").getChild("lastMatch").getChild("mat
chPrice").getValue());%x/fontx/divx/td>
ctdxdiv align="center"xfont size="-
1 ">c%out.print(stock.getChild("matched") .getChild("lastMatch") .getChild("mat
chTime") .getValueO) ;%x/fontx/divx/td>
ctdxdiv align="center"xfont size="-l">
c°/oout.print(stock.getChild("matched") .getChild("matchedShares") .getValueO);
%x/fontx/divx/td>
c/tr>
c%
}
%>
c/table>
57
<p> </p>
</div>
<p align="center"x/form> </p>
<p align="center"> </p>
</td>
</trx/table>
</tdx/tr>
</table>
</body>
</html>
// end getTopList.java
getQuote.jsp
58
<TD height="74" align=middle vAlign=center> <dlv align="center"xfont
color="#0066FF" size="4" face="Georgia, Times New Roman, Times,
serif'xstrongxemxfont color="#FFCCFF">Real-Time
Finance Management System</fontxbr>
</emx/strongx/font>
chr width="400" color="#FFOOOO">
<font color="#0066FF" size="4" face="Georgia, Times New Roman, Times,
serif'xstrongxem>
c/emx/strongx/fontx/divx/TD>
</TR>
</TBODY>
c/TABLE>
<br>
<table align="center" width="100%">
<tr>
ctd width="14%">
<table align="left" cellpadding="8" cellspacing="2" width="100%">
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa
href="../index.html">Home</ax/fontx/strongx/fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif’>Portfoliocbr>
Management</fontx/strongx/fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif 'xa
href="reminders/index.html">Remindersc/ax/fontx/strongx/fontx/divx/td>
c/tr>
ctr>
59
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa href="debt/index.htxnl">Debt
Planning</ax/fontx/strongx/fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa
href="expenditures/index.html">Expenditures</ax/fontx/strongx/fontx/divx/
td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont size="-l"
face="Arial, Helvetica, sans-serif'xa href="account/index.html">Account
Informationc/ax/fontx/strongx/fontx/divx/td>
c/tr>
c/table>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/p>
cp> c/px/td>
ctd width="86%"xtable width="100%"xtrxtd>
cp align="center">
cform name="forml" method="post" action="getQuote.jsp">
cp align="center"xfont color="#FFFFFF"xstrong>Get Quote:
c/strongx/font>
cinput name="stockName" type="text" id="stockName" size="10">
cinput type="submit" name="Submit" value="GO">
60
</p>
</form> <p align="center"xfont color="#FFFFFF">cstrong>Here is the
quote that you requested for:
<% out.print(request.getParameter("stockName"));%>
</strongx/fontx/p>
<p align="center"xfont color="#FFFFFF">
<jsp:useBean id="date" class="DateBean">
</jsp:useBean>
<jsp:useBean id="si" class="StockInfo">
</jsp:useBean>
</font> </p>
<p align="center"xfont color="#FFFFFF">
<%
//Stocklnfo si = new StocklnfoO;
String stockQuote =
si.getSingleQuote(request.getParameter("stockName")):
//out.println("My Name is Muku'j;
/ /out.println(stockQuote);
//out.println("cbr>");
//out.println(date.getDateO);
%>
</fontx/code> </p>
<div align="center">
ctable width="50%" border="2" align="center" cellpadding="2"
cellspacing="2">
ctr>
ctd colspan="2"xdiv align="center">
ch2> cfont color="#66FFFF" face="Georgia, Times New Roman, Times,
serif’>
c%out.print(request.getParameter("stockName"));%>
c/fontx/h2>
c/divx/td>
c/tr>
ctr>
61
<td colspan="2"xdiv align="center"xfont color="#66FFFF"
face="Georgia, Times New Roman, Times, serif>
<%out.print(date.getDate()) ;%>
</fontx/div>
<div align="center"x/divx/td>
c/tr>
<tr>
<tdxdiv align="center"xfont color="#66FFFF" face="Georgia, Times New
Roman, Times, serif'>Market
Session </fontx/divx/td>
<tdxdiv align="center"xfont color="#66FFFF">
<%out.print(si.getMarketSession()); %>
</fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#66FFFF">Match
Price:</fontx/divx/td>
ctdxdiv align="center"xfont color="#66FFFF">
<%out.print(""+si.getMatchPriceO);%>
</fontx/divx/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#66FFFF">Match Time:
c/fontx/divx/td>
ctdxdiv align="center"xfont color="#66FFFF">
c%out.print(si.getMatchTime()); %>
c/fontx/divx/td>
c/tr>
ctr>
ctdxdiv align="center"xfont color="#66FFFF">Matched Shares:
c/fontx/divx/td>
ctdxdiv align="center"xfont color="#66FFFF">
c%out.print(si.getMatchedSharesO):%>
c/fontx/divx/td>
c/tr>
62
</table>
</div>
<p align="center"> </p>
<p align="center"x/form> </p>
</td>
</trx/table>
</td>
</trx/table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
// end getQuote.jsp
getTimeAndSales.jsp
<%@ page import="rfms_modules .*"%>
<%@ page import= "org.jdom.*, org.jdom.input.*,
org.apache.xerces.parsers.*, java.sql.*,java.util.List"%>
<%@ page language="java" contentType="text/html"%>
<%@ page autoFlush = "true"%>
<%@ page session = "false"%>
<jsp:useBean id="ts" scope="page"
class="rfms_modules.TimeAndSales" />
<html>
63
<head>
ctitle>Real-Time Finance Management System - Portfolio
Managementc/1 i 11e>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1">
</head>
<td width="14%">
ctable align="left" cellpadding="8" cellspacing="2" width="100%">
<tr>
ctdxdiv align=" center "xfont color="#FFFFFF">cstrong>cfont
size="-l" face="Arial, Helvetica, sans-serif"><a
href=" . . /index.html">Homec/a></font></strongx/fontx/div>c/td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont
size="-l" face="Arial, Helvetica, sans-serif">Portfolio<br>
Managementc/f on tx/s trongx/f ontx/divx/td>
</tr>
<tr>
ctdxdiv align=" center "xfont color="#FFFFFF" xstrongxf ont
size="-l" face="Arial, Helvetica, sans-serif"xa
hre f =" reminders / index. html" >Reminder sc / ax / f ontx / s t rongx / f ont >c / div
x/td>
</tr>
<tr>
ctdxdiv align="center">cfont color="#FFFFFF"xstrongxfont
size="-l" face="Arial, Helvetica, sans-serif "xa
hre f ="debt/index.html">Debt
Planning< / ax / f ontx / s trongx / f ontx / divx / td>
</tr>
<tr>
ctdxdiv align=" center "xfont color="#FFFFFF" xstrongxf ont
size="-l" face="Arial, Helvetica, sans-serif "xa
href =" expenditures / index. html" >Expendi turesc /ax / f ontx / strongx / font
x/divx/td>
64
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont
size="-l" face="Arial, Helvetica, sans-serif "xa
href="account/index.html">Account
Inf ormationc/ ax / f ontx / strongx / f ontx /divx/ td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"><strongxfont
size="-l" face="Arial, Helvetica, sans-serif "xa
href="expense/index.html">Expense
Plannerc / ax / f ontx / s trongx / f ont >< / divx / td>
</tr>
<tr>
ctdxdiv align="center"xfont color="#FFFFFF"xstrongxfont
size="-l" face="Arial, Helvetica, sans-serif "xa
hre f =" bills/index.html">Bi11s
& Dues</ax/fontx/strongx/fontx/divx/td>
</tr>
</table>
cp> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
cp> c/p>
cp> </p>
<p> </p>
cp> </p>
cp> c/p>
<p> c /px / td>
ctd width="86%"><table width="100%"xtrxtd>
<p align="center">
cform name="forml" method="post" action="getQuote.jsp">
<p align="right">cfont color="#FFFFFF"xstrong>cfont
size="-l">Get
Quote: </fontx/strongx/font> cfont size="-l">
cinput name="stockName" type="text" id="stockName"
size="10 ">
cinput type="submit" name="Submit" value="G0">
c/font> </p>
</form>
<div align="center">
cpxstrongxfont color="#FF6666" size="6">Time and
Sales</fontxbrxbr>
cfont color="FF6666" size="4">The last
<%out.print(" ");
String recNumbString=
request.getParameter("recNumb");
int recNumbInt=
Integer.parselnt(recNumbString);
String symbol =
request.getParameter("symbol");
out.print(recNumbString) ;
out.printC ");
65
if (recNumbInt>l) {out.print("Sales");} else
{out.print("Sale");}
out.print(" for "+symbol);
%>
< / f ont>< / s trongx /p>
ctable width="100%" border="2" align="center"
cellpadding="2" cellspacing="2">
<tr>
<tdxdiv align="center"xstrongxfont size="~
1" >#</f ontx/strongx/divx/td>
ctdxdiv align=" center "xstrongxfont size="-
1" >MATCHED<br>SHARES< / f ontx I s trongx / divx / td>
ctdxdiv align=" center "xstrongxfont size="-
1" >PRICEc / f ontx / s trongx / divx / td>
ctdxdiv align=”center"xstrongxfont size="-
1" >TIMEc / f ont>c / s trongx / divx / td>
ctdxdiv align=" center "xstrongxfont size="-
1" >MATCHcBR>TYPEc / f ontx / s trongx / divx / td>
ctdxdiv align="center"xstrongxfont
size="-l" >REFERENCEcBR>NUMBERc / f ontx / s trongx / divx / td>
c/tr>
c%
Document d =
ts.buildDocument(symbol,recNumblnt);
Element root = d.getRootElement();
Element matchList =
root.getChild("stock").getChild("matched").getChild("matchList");
List matches = matchList.getChildren();
for (int i=0, size=matches.size();
icsize;i++) {
Element match =
(Element)matches.get(i); %>
ctr>
ctdxdiv align="center"xfont size="-
l”x%out .print (i+1) ; %> .c/f ontx/divx/ td>
ctdxdiv align="center">cfont size="-
l"x%out .print (match.getChild("matchedShares") .getValueO ) ;%x/fontx
/divx/td>
ctdxdiv align="center"xfont size="~
l"x%out .print (match. getChild( "matchPrice") .getValueO ) ; %x/fontx/di
vx/td>
ctdxdiv align="center">cfont size="-
1" >c%out .print (match. getChild ("matchTime") .getValueO ) ; %x/fontx/div
>c/td>
ctdxdiv align=11 center">cfont size="-
1 ">c%out .print (match.getChild("matchType”) .getValue ()) ; %x/fontx/div
>c/td>
ctdxdiv align="center"xfont size="-
l"x%out .print (match.getAttribute ("refNumb") . getValue () ) ; %x/fontx/d
ivx/td>
c/tr>
c% } %>
c/table>
cp> c/p>
66
</div>
<p align="center"> </p>
<p align="center"x/form> </p>
</td>
</tr></table>
</td>
</trx/table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
// end getTimeAndSales.jsp
web.xml
<?xml version="1.0" encoding="ISO-8859-l"?>
<!—
Copyright 2004 The Apache Software Foundation
http://www.apache.Org/licenses/LICENSE-2.0
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www. w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-
app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
67
<!— JSPC servlet mappings end —>
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>
jdbc/rfms
</res-ref-name>
<res-type>
j avax. sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
</web-app>
// end web.xml
server.xml
<!— Example Server Configuration File —>
<!- Note that component elements are nested corresponding to their
parent-child relationships with each other —>
<!— Comment these entries out to disable JMX MBeans support used for the
administration web application —>
cListener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
•^Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
cListener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
68
<GlobalNamingResources>
</GlobalNamingResources>
69
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
<Connector=”8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to 0 ->
<!-- Note : To use gzip compression you could set the following properties :
compression^' on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->
c!~ An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host). ->
c!~ Define the top level container in our container hierarchy —>
/c!-cEngine name="Catalina" defaultHost="localhost">->
cEngine name="Catalina" defaultHost="localhost">
<!-- The request dumper valve dumps useful debugging information about
the request headers and cookies that were received, and the response
70
headers and cookies that were sent, for all requests received by
this instance of Tomcat. If you care only about requests to a
particular virtual host, or a particular application, nest this
element inside the corresponding <Host> or <Context> entry instead.
<!-- Because this Realm is here, an instance will be shared globally ->
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. —>
<RealmclassName="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!- Comment out the old realm but leave here for now in case we
need to go back quickly ~>
<!--
<Realm className="org.apache.catalina.realm.MemoryRealm" />
-->
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC —>
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.gjt.mm.mysql.Driver"
connectionURlL="jdbc:mysql://localhost/authority"
connectionName="test" connectionPassword="test"
userTab!e="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURJ>="jdbc:oracle:thin: @ntserver: 1521 :ORCL"
connectionName="seott" connectionPassword="tiger"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
->
71
<!--
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="sun.jdbc.odbc.JdbcOdbcDriver"
connectionURL= "j dbc: odbc: CATALINA"
userTable="users" userNameCol="user_name" userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name" />
-->
mcastAddr = the multicast address, has to be the same for all the nodes
mcastPort = the multicast port, has to be the same for all the nodes
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would
be the same amount of threads as nodes
tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
in case of multiple ethernet cards,
auto means that address becomes
InetAddress.getLocalHost().getHostAddress()
tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
has a wakup bug in java.nio. Set to 0 for no timeout
72
printToScreen = true means that managers will also print to std.out
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has
been called.
false means to replicate the session after each request.
false means that replication would work for the following piece of code: (only for
SimpleTcpReplicationManager)
<%
HashMap map = (HashMap)session.getAttribute("map'j;
map.put("key","value");
%>
replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
* Pooled means that the replication happens using several sockets in a synchronous
way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting
except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To
use this, also increase the nr of tcp threads that you have dealing with replication.
* Synchronous means that the thread that executes the request, is also the
thread the replicates the data to the other nodes, and will not return until all
nodes have received the information-
* Asynchronous means that there is a specific 'sender' thread for each cluster node,
so the request thread will queue the replication request into a "smart" queue,
and then return to the client.
The "smart" queue is a queue where when a session is added to the queue, and the
same session
already exists in the queue from a previous request, that session will be replaced
in the queue instead of replicating two requests. This almost never happens, unless
there is a
large network delay.
-->
<!--
When configuring for clustering, you also add in a valve to catch all the requests
coming in, at the end of the request, the session may or may not be replicated.
A session is replicated if and only if all the conditions are met:
1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
2. a session exists (has been created)
3. the request is not trapped by the "filter" attribute
The filter attribute is to filter out requests that could not modify the session,
hence we don't replicate the session after the end of this request.
The filter is negative, ie, anything you put in the filter, you mean to filter out,
ie, no replication will be done on requests that match one of the filters.
The filter attribute is delimited by ;, so you can't escape out; even if you wanted to.
filter-'.*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
ending with .gif and .js are intercepted.
73
The deployer watches a directory (watchDir) for WAR files when watchEnabled="true
When a new war file is added the war gets deployed to the local instance,
and then deployed to the other instances in the cluster.
When a war file is deleted from the watchDir the war is undeployed locally
and cluster wide
cCluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
cMembership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
cReceiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress=" auto"
tcpListenPort="4001"
tcpSelectorTimeout=" 100"
tcpThreadCount=" 6 "/>
cSender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout=" 15000"/>
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
cDeployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
</Cluster>
74
<!--
cValve className="org.apache.catalina.authenticator.SingIeSignOn" />
~>
<!— Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
->
<!-
cValve className="org.apache.catalina. valves. AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resoiveHosts="false"/>
->
<!— Access log processes all requests for this virtual host. By
default, log files are created in the "logs" directory relative to
$CATALINA_HOME. If you wish, you can specify a different
directory with the "directory" attribute. Specify either a relative
(to $CATALINA_HOME) or absolute path to the desired directory.
This access log implementation is optimized for maximum performance,
but is hardcoded to support only the "common" and "combined" patterns.
-->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>
-->
<!-
| Begin MyWebApp context definition.
+-->
<!-
| End MyWebApp context definition.
+-->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_rfms" suffix=".txt" timestamp="true"/>
<ResourceParams name="jdbc/rfmsDS">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!--
| The JDBC connection URL for connecting to your MySQL DB.
75
| The autoReconnect=true argument to the URL makes sure that the
j MySQL JDBC Driver will automatically reconnect if mysqld closed
| the connection, mysqld by default closes idle connections after
| 8 hours.
+->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/rfms
autoReconnect=true</value>
</parameter>
<!--
| MySQL username and password for DB connections.
+->
<!-
[ Class name for MySQL JDBC driver.
+-->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!—
| Maximum number of DB connections in pool. Make sure you
| configure your mysqld max_connections large enough to handle
| all of your DB connections. Set to 0 for no limit.
+->
<parameter>
<name>maxActive</name>
<value> 100</value>
</parameter>
<!—
| Maximum number of idle DB connections to retain in pool.
| Set to 0 for no limit.
+-->
<parameter>
<name>maxldle</name>
<vaiue>30</value>
</parameter>
<!-
| Maximum time to wait for a DB connection to become available
| in ms, in this example 10 seconds. An exception is thrown if
| this timeout is exceeded.
| Set to -1 to wait indefinitely.
+->
<parameter>
<name>maxWait</name>
<value> 10000</value>
76
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>
// end server.xml
77
REFERENCES
78