Académique Documents
Professionnel Documents
Culture Documents
QWEST DUF SPLITTER PROJECT is designed to keep record of all the data of
the DUF’s, i.e., (DAILY USAGE FILES). These files are used by telecom
companies. They keep the data in numeric form, which shows the time taken by
particular customer.
Main objective of this project is to fetch the data from the DUF’s and then store
them in a separate database. It also informs all the customers about the data on
their email id.
This project has been designed for the company United Telecom LLC and the
distributed networks which work under this company by the planetwire company.
Initially all the proceedings were very cumbersome and difficult.
Main Telecom server of the Qwest company gives the data in the form of DUF’s
(Daily Usage Files). Then company maintaining the data fetches the files through
FTP (File Transfer Protocol) after that data is maintained in Excel sheets and
with lots of effort its formatting is done. Then this data is passed to distributed-
network to use it to prepare the bills and keep the data of all the customers
separately. This whole procedure to maintain the data used to take place
everyday. This is a very long and difficult process, which requires more
employees also. Therefore there is need of some efficient way to overcome this
problem. Application should be efficient as well as it should save the time and
manpower. Thus this project has been implemented which gives solution to all
the problems.
Thus this project has been developed to overcome all these problems.
This project has been implemented to help in keeping data of all the customers
who are availing the services of United Telecom LLC company in New York. This
company uses the telecom server of Qwest company for all the proceedings.
Data from this server comes to United Telecom company in the form of DUF
(Daily Usage Files). These DUF’s contain the data in numeric form as these are
output from an electronic device. Therefore the foremost function of project is to
read all DUF’s. There is an ASCII code file in which meaning of the sequence of
numbers from a particular location upto a particular location is defined. According
to data in ASCII file DUF is splitted and final data is sent to the email id of the
customer. File which contains all the details of the duration to which customer
has talked is called one Ani file. Each customer has more than one ANI files. In
this project client is the distributed-network, which works under the United LLC
1
company. They need data to be properly organized so that proper bill calculation
can be performed. Thus here a proper backend is also used which keeps all the
data of customer in the database. Main steps followed in the project preparation
are:
This project has been implemented using advance java. Java servlets and Java
Server Pages technologies have been used to implement it technically. The main
reason to choose this language is its platform-independency and to use its
features of server side programming. For server side programming tomcat server
has been chosen. For the backend MySQL database has been used. Creation
and compilation of all the programs have been implemented in Eclipse IDE
(Integrated Development Environment). Also HTML, XML files have been used
as well as some java scripting has also done in JSP files. This is the brief
introduction of the whole project. Now let’s explore the things in depth.
2
1.0 ABOUT ORGANIZATIONS
1.1 QWEST
Qwest is committed to providing quality voice, Internet, data and video solutions
to benefit residential, business and government customers across the country.
They are deeply entrenched in their local 14-state western and mid-western
service territory and strive to provide innovative, quality products combined with
superior customer service. In addition, Corporate Sponsorship and Qwest
Foundation opportunities demonstrate their commitment to rewarding the
communities they serve.
The Qwest® Network puts dependable global communication within our reach.
With Qwest, we receive access to one of the largest, most technically advanced
voice and data networks in the world ensuring we can stay in touch, anytime and
anywhere.
For years, Qwest’s state-of-the-art IP network has been transferring voice, video,
and data across the globe for businesses of all sizes. The Qwest network has the
capacity and advanced capabilities to support today’s mission critical applications
such as Voice over IP (VoIP), as well as bandwidth-intensive business
applications such as Enterprise Resource Planning, Customer Relationship
Management, and other business-to-business functions. These business
applications require a network that is flexible to be tuned to our exact
specifications for reliability, performance, and service.
From a technical perspective, the Qwest OC-192 IP network backbone is
engineered for minimal packet loss and network congestion. MPLS fast re-route
is used between every core router in the network ensuring a quicker recovery
time over synchronous optical network (SONET). Networking Ports are available
from 56 Kilobits per second (Kbps) to 2.4 Gigabits per second (Gbps). While the
Qwest public and private peering arrangements are extensive (86 Gbps per
second utilizing 99 percent private connections), cold potato routing (Qwest
transmits customer traffic on the Qwest network for as long as possible) virtually
eliminates most of the latency issues faced by other service providers. The
Qwest OC-192 IP network is one of the most advanced networks available,
offering best–in–class service level agreements and some of the highest
customer access speeds in the industry today.
1.2 PLANETWIRE
3
professionally engaged in the field of Internet Telephony solutions, Carrier
Solutions and VOIP based Call Center solutions. They are collaborated with
major US, UK and Australia based companies in the area of IP Telephony and
Call Center related business. Planetwire is having its corporate office in New
York, USA to operate Global Telephony Network. They are having highly skilled
professionals who manage the whole network efficiently. In USA they are having
their network control facility powered with SoftSwitches and having business
development office. In India they are having their support center with well
equipped with expert team.
They provide the support to start and run Calling Card business anywhere in the
globe. For this they provide all technology support and operational support to get
into high profitability business. They manage the LCR (least call rate) facility to
their calling card business partner.
Beyond this telecommunication area they have also expanded their business in
the area of SMS (Sort Messaging Service) and High-end Software Development.
Planetwire provides the technical solutions of Bulk SMS which can be send
globally to Hand held devices (mobiles, communicators, palm devices, pagers).
They have well experienced team for Software Development and Web
Designing. They are providing customized applications for Handheld Devices.
4
Founded in 1996, United Telecom has established itself as a leading provider of
Telecommunications services in the New York Tri-State-Area. United Telecom
has attributed its success primarily to is commitment to providing superior
telecommunication expertise and customer service. United Telecom has grown in
sales, staff and business focus since its inception, and has established itself as
an extremely reliable and resourceful company. Goal at United Telecom is to
provide the highest level of customer service to all the clients.
1.3.1 Services
LOCAL SERVICES
One of the services is “Unlimited calls for one monthly price”. It is all local, local
tolls, and long distance calls anywhere in the U.S. Call anywhere, anytime and
talk as long as customer want. Some other popular features include Call Waiting,
Caller ID, and Three-Way Calling.
CALLING CARDS
5
United Telecom's calling card is any easy-to-use, feature-rich calling card
designed to meet the needs of traveling employees by combining a basic feature
set with outstanding reliability and competitive rates. This card provides toll-free
access from Canada and anywhere in the U.S. including Alaska, Hawaii, Puerto
Rico, and the U.S. Virgin Islands to many direct-dial countries worldwide.
Calling cards provide business with voice and data connections from over 140
countries via toll-free access numbers. It has no capacity constraints and
features one consistent dialing sequence.
TOLL FREE
Flexible toll free services enable all customers to conveniently communicate with
their business. Company’s intelligent network lets them route incoming toll-free
calls according to business needs and, in most cases, without any special
equipment or significant expense.
FULL SERVICE T1
2.0 INTRODUCTION
6
NEED OF THE PROJECT
File Splitter is designed to keep record of all the data of the DUF’s, i.e., (DAILY
USAGE FILES). These files are used by telecom companies. They keep the data
in numeric form, which shows the time taken by particular customer. To keep the
track for the purpose of billing, initially some different approach was followed.
Main Telecom server gives the data in the form of DUF’s. Then company
maintaining the data fetches the files through FTP (File Transfer Protocol).after
that data is maintained in Excel sheets and with lots of effort it’s formatting is
done. This was a very long and difficult process, which requires more employees
also. Therefore there was need of some efficient way to overcome this problem.
Application should be efficient as well as it should save the time and manpower.
Thus this project has been implemented which gives solution to all the problems.
Main objective of this project is to fetch the data from the DUF’s and then store
them in a separate database. It also informs all the customers about the data on
their email id.
This project has been implemented using advance java technologies. Main
reason of opting java is its platform independency and to utilize its client server
techniques. It uses the basic concepts of core java, but its main implementation
has been done through the servlets and JSP (java Server pages) and servlet
runs in the tomcat environment. It also uses database MySql as its backend.
3.0 METHODOLOGIES
7
The main tools which have been used in this project are as follows:
Core Java
J2EE
JDBC(Java Database Connectivity)
Servlets
JSP(Java Server Pages)
Jakarta-Tomcat environment
MySql
MS Front Page
Javascript
What Is Java?
8
Java Is Platform-Independent
Platform independence is one of the most significant advantages that Java has
over other programming languages, particularly for systems that need to work on
many different platforms. Java is platform-independent at both the source and
the binary level. Platform-
independence is a program’s
capability of moving easily
from one computer system to
another.
Figure 3.1 shows the result of this system: multiple executable programs for
multiple systems. Things are different when we write code in Java. The Java
9
development environment has two parts: a Java compiler and a Java interpreter.
The Java compiler takes our Java program and instead of generating machine
codes from our source files, it generates bytecodes.
Java Is Object-Oriented
3.2 J2EE
3.2.1 Overview
To reduce costs and fast-track application design and development, the Java 2
Platform, Enterprise Edition (J2EE ) provides a component-based approach to
the design, development, assembly, and deployment of enterprise applications.
The J2EE platform offers a multitiered distributed application model, reusable
components, a unified security model, flexible transaction control, and web
services support through integrated data interchange on Extensible Markup
Language (XML)-based open standards and protocols.
10
Not only can we deliver innovative business solutions to market faster than ever,
but also our platform-independent J2EE component-based solutions are not tied
to the products and application programming interfaces (APIs) of any one
vendor. Vendors and customers enjoy the freedom to choose the products and
components that best meet their business and technological requirements.
Container Services
Containers are the interface between a component and the low-level platform-
specific functionality that supports the component. Before a web component,
enterprise bean, or application client component can be executed, it must be
assembled into a J2EE module and deployed into its container.
The assembly process involves specifying container settings for each component
in the J2EE application and for the J2EE application itself. Container settings
customize the underlying support provided by the J2EE server, including services
such as security, transaction management, Java Naming and Directory Interface
(JNDI) lookups, and remote connectivity. Here are some of the highlights:
11
components within the same J2EE application can behave differently
based on where they are deployed. For example, an enterprise bean can
have security settings that allow it a certain level of access to database
data in one production environment and another level of database access
in another production environment. The container also manages non-
configurable services such as enterprise bean and servlet life cycles,
database connection resource pooling, data persistence, and access to
the J2EE platform APIs section. Although data persistence is a non-
configurable service, the J2EE architecture lets us override container-
managed persistence by including the appropriate code in our enterprise
bean implementation when we want more control than the default
container-managed persistence provides. For example, we might use
bean-managed persistence to implement our own finder (search) methods
or to create a customized database cache.
Container Types
J2EE server
J2EE server is the runtime portion of a J2EE product. A J2EE server provides
EJB and web containers.
EJB container manages the execution of enterprise beans for J2EE applications.
Enterprise beans and their container run on the J2EE server.
12
Web container
Web container manages the execution of JSP page and servlet components for
J2EE applications. Web components and their container run on the J2EE server.
Applet container
Figure 3.4 illustrates the availability of the J2EE 1.4 platform APIs in each J2EE
container type. The following sections give a brief summary of the technologies
required by the J2EE platform and the J2SE enterprise APIs that would be used
in J2EE applications.
13
An Enterprise JavaBeans (EJB ) component, or enterprise bean, is a body of
code having fields and methods to implement modules of business logic. We can
think of an enterprise bean as a building block that can be used alone or with
other enterprise beans to execute business logic on the J2EE server.
As mentioned earlier, there are three kinds of enterprise beans: session beans,
entity beans, and message-driven beans. Enterprise beans often interact with
databases. One of the benefits of entity beans is that we do not have to write any
SQL code or use the JDBC API directly to perform database access
operations; the EJB container handles this for us. However, if we override the
default container-managed persistence for any reason, we will need to use the
JDBC API. Also, if we choose to have a session bean access the database, we
must use the JDBC API.
The Java Message Service (JMS) API is a messaging standard that allows J2EE
application components to create, send, receive, and read messages. It enables
distributed communication that is loosely coupled, reliable, and asynchronous.
The Java Transaction API (JTA) provides a standard interface for demarcating
transactions. The J2EE architecture provides a default auto commit to handle
transaction commits and rollbacks. An auto commit means that any other
applications that are viewing data will see the updated data after each database
read or write operation. However, if our application performs two separate
database access operations that depend on each other, we will want to use the
JTA API to demarcate where the entire transaction, including both operations,
begins, rolls back, and commits.
14
JavaMail API
J2EE applications use the JavaMail API to send email notifications. The
JavaMail API has two parts: an application-level interface used by the application
components to send mail, and a service provider interface. The J2EE platform
includes JavaMail with a service provider that allows application components to
send Internet mail.
The Java API for XML Processing (JAXP) supports the processing of XML
documents using Document Object Model (DOM), Simple API for XML (SAX),
and Extensible Stylesheet Language Transformations (XSLT). JAXP enables
applications to parse and transform XML documents independent of a particular
XML processing implementation.
JAXP also provides namespace support, which lets us work with schemas that
might otherwise have naming conflicts. Designed to be flexible, JAXP lets us use
any XML-compliant parser or XSL processor from within our application and
supports the W3C schema.
The Java API for XML-based RPC (JAX-RPC) uses the SOAP standard and
HTTP, so client programs can make XML-based remote procedure calls (RPCs)
over the Internet. JAX-RPC also supports WSDL, so we can import and export
WSDL documents. With JAX-RPC and a WSDL, we can easily interoperate with
clients and services running on Java-based or non-Java-based platforms such as
.NET. For example, based on the WSDL document, a Visual Basic .NET client
can be configured to use a web service implemented in Java technology, or a
web service can be configured to recognize a Visual Basic .NET client.
JAX-RPC relies on the HTTP transport protocol. Taking that a step further, JAX-
RPC lets we create service applications that combine HTTP with a Java
technology version of the Secure Socket Layer (SSL) and Transport Layer
Security (TLS) protocols to establish basic or mutual authentication. SSL and
TLS ensure message integrity by providing data encryption with client and server
authentication capabilities.
15
Authentication is a measured way to verify whether a party is eligible and able to
access certain information as a way to protect against the fraudulent use of a
system or the fraudulent transmission of information. Information transported
across the Internet is especially vulnerable to being intercepted and misused, so
it's very important to configure a JAX-RPC web service to protect data in transit.
The SOAP with Attachments API for Java (SAAJ) is a low-level API on which
JAX-RPC depends. SAAJ enables the production and consumption of messages
that conform to the SOAP 1.1 specification and SOAP with Attachments note.
Most developers do not use the SAAJ API, instead using the higher-level JAX-
RPC API.
The Java API for XML Registries (JAXR) lets we access business and general-
purpose registries over the web. JAXR supports the ebXML Registry and
Repository standards and the emerging UDDI specifications. By using JAXR,
developers can learn a single API and gain access to both of these important
registry technologies.
Additionally, businesses can submit material to be shared and search for material
that others have submitted. Standards groups have developed schemas for
particular kinds of XML documents; two businesses might, for example, agree to
use the schema for their industry's standard purchase order form. Because the
schema is stored in a standard business registry, both parties can use JAXR to
access it.
The J2EE Connector architecture is used by J2EE tools vendors and system
integrators to create resource adapters that support access to enterprise
information systems that can be plugged in to any J2EE product. A resource
adapter is a software component that allows J2EE application components to
access and interact with the underlying resource manager of the EIS. Because a
resource adapter is specific to its resource manager, typically there is a different
resource adapter for each type of database or enterprise information system.
16
Connector architecture are complementary technologies for enterprise
application integration (EAI) and end-to-end business integration.
JDBC API
The JDBC API lets we invoke SQL commands from Java programming language
methods. We use the JDBC API in an enterprise bean when we override the
default container-managed persistence or have a session bean access the
database. With container-managed persistence, database access operations are
handled by the container, and our enterprise bean implementation contains no
JDBC code or SQL commands. We can also use the JDBC API from a servlet or
a JSP page to access the database directly without going through an enterprise
bean.
The JDBC API has two parts: an application-level interface used by the
application components to access a database, and a service provider interface to
attach a JDBC driver to the J2EE platform.
The Java Naming and Directory Interface (JNDI) provide naming and directory
functionality. It provides applications with methods for performing standard
directory operations, such as associating attributes with objects and searching for
objects using their attributes. Using JNDI, a J2EE application can store and
retrieve any type of named Java object.
J2EE naming services provide application clients, enterprise beans, and web
components with access to a JNDI naming environment. A naming environment
allows a component to be customized without the need to access or change the
component's source code. A container implements the component's environment
and provides it to the component as a JNDI naming context.
17
are named within the subcontext java:comp/env/ejb, and JDBC DataSource
references in the subcontext java:comp/env/jdbc.
The Java Authentication and Authorization Service (JAAS) provide a way for a
J2EE application to authenticate and authorize a specific user or group of users
to run it.
The J2EE APIs enable systems and applications integration through the
following:
18
3.3.1 Introduction to JDBC
SQL Server
DB2
My SQL
MS Access
Sybase
Java
Application
ODBC
JDBC-
ODBC
Bridge
Database working as
middleware
19
Type 2: Native API Partly Java Driver
Java
Native Application
Database
Library
JDBC-
Driver
Database working as
middleware
The Native to API driver converts JDBC commands to DBMS. It converts specific
native calls. Here no driver is written by Java unlike ODBC where JDBC-ODBC
driver written by Java. Here partial difference is that driver is written by specific
company only. This is a native application.
Java
Middleware
Application
Database working as
middleware
20
Type 4: Native-protocol Pure Java Driver
This is a pure java driver that communicates directly to database. Like oracle has
made its own driver.
Java
Application
JDBC-
Driver
Database
To create the database, we can feed SQL statements to an ODBC data source
via the JDBC-ODBC bridge. First, we will have to create an ODBC data source.
We have many choices – we could, for example, connect an Access, SQL
Server, Oracle or Sybase database.
To enter the data into the TestDB database, create a Java application that
follows these steps:
1. Load the JDBC-ODBC bridge: It tells the JDBC classes how to talk to a data
source. For the class JDBC-ODBC driver
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connectioncon=DriverManager.getConnection((URL,username,password);
where the username and password are empty strings, in this case because text
files acting as ODBC data source cannot have such attributes.
21
3. Send SQL statements to create the table: Ask the connection object for a
statement object.
Metadata: We can access the information about the database as a hole, or about
a particular query ResultSet using Stored Procedures.
SQL Exceptions
The SQLException is the basis of all JDBC Exceptions. It consists of all three
pieces of information a, String message, another String containing the XOPEN
SQL state, and adiver/source specific int for an additional error code.
In addition, multiple SQL Exception instances can be chained together.
SQL Warnings
3.4 SERVLETS
22
When implementing a generic service, we can use or extend the GenericServlet
class provided with the Java Servlet API. The HttpServlet class provides
methods, such as doGet and doPost, for handling HTTP-specific services.
The life cycle of a servlet is controlled by the container in which the servlet has
been deployed. When a request is mapped to a servlet, the container performs
the following steps.
If the container needs to remove the servlet, it finalizes the servlet by calling the
servlet's destroy method.
Servlets are Java technology's answer to CGI programming. They are programs
that run on a Web server and build Web pages. Building Web pages on the fly is
useful (and commonly done) for a number of reasons:
The Web page is based on data submitted by the user. For example the
results pages from search engines are generated this way, and programs
that process orders for e-commerce sites do this as well.
The data changes frequently. For example, a weather-report or news
headlines page might build the page dynamically, perhaps returning a
previously built page if it is still up to date.
The Web page uses information from corporate databases or other such
sources. For example, we would use this for making a Web page at an on-
line store that lists current prices and number of items in stock.
Java servlets are more efficient, easier to use, more powerful, more portable, and
cheaper than traditional CGI and than many alternative CGI-like technologies.
Efficient. With traditional CGI, a new process is started for each HTTP
request. If the CGI program does a relatively fast operation, the overhead
of starting the process can dominate the execution time. With servlets, the
Java Virtual Machine stays up, and each request is handled by a
lightweight Java thread, not a heavyweight operating system process.
Similarly, in traditional CGI, if there are N simultaneous request to the
same CGI program, then the code for the CGI program is loaded into
memory N times. With servlets, however, there are N threads but only a
23
single copy of the servlet class. Servlets also have more alternatives than
do regular CGI programs for optimizations such as caching previous
computations, keeping database connections open, and the like.
Convenient. Besides the convenience of being able to use a familiar
language, servlets have an extensive infrastructure for automatically
parsing and decoding HTML form data, reading and setting HTTP
headers, handling cookies, tracking sessions, and many other such
utilities.
Powerful. Java servlets let we easily do several things that are difficult or
impossible with regular CGI. For one thing, servlets can talk directly to the
Web server (regular CGI programs can't). This simplifies operations that
need to look up images and other data stored in standard places. Servlets
can also share data among each other, making useful things like database
connection pools easy to implement. They can also maintain information
from request to request, simplifying things like session tracking and
caching of previous computations.
Portable. Servlets are written in Java and follow a well-standardized API.
Consequently, servlets written for, say I-Planet Enterprise Server can run
virtually unchanged on Apache, Microsoft IIS, or WebStar. Servlets are
supported directly or via a plugin on almost every major Web server.
Inexpensive. There are a number of free or very inexpensive Web servers
available that are good for "personal" use or low-volume Web sites.
However, with the major exception of Apache, which is free, most
commercial-quality Web servers are relatively expensive. Nevertheless,
once we have a Web server, no matter the cost of that server, adding
servlet support to it (if it doesn't come preconfigured to support servlets) is
generally free or cheap.
Java Server Pages (JSP) is a technology that lets we mix regular, static HTML
with dynamically-generated HTML. Many Web pages that are built by CGI
programs are mostly static, with the dynamic part limited to a few small locations.
But most CGI variations, including servlets, make we generate the entire page
via our program, even though most of it is always the same. JSP lets we
create the two parts separately. Here's an example:
24
To access our account settings, click
<A HREF="Account-Settings.html">here.</A></SMALL>
<P>
Regular HTML for all the rest of the on-line store's Web page.
</BODY></HTML>
Apache Tomcat is the servlet container that is used in the official Reference
Implementation for the Java Servlet and JavaServer Pages technologies. The
Java Servlet and JavaServer Pages specifications are developed by Sun under
the Java Community Process.
25
Apache Tomcat is developed in an open and participatory environment and
released under the Apache Software License. Apache Tomcat is intended to be a
collaboration of the best-of-breed developers from around the world.
For the complete description of the Tomcat distribution, each folder can be found
in the README.txt file, residing in the root directory of our Tomcat installation.
/bin - Startup, shutdown, and other scripts. The *.sh files (for Unix
systems) are functional duplicates of the *.bat files (for Windows systems).
Since the Win32 command-line lacks certain functionality, there are some
additional files in here.
/conf - Configuration files and related DTDs. The most important file in
here is server.xml. It is the main configuration file for the container.
/logs - Log files are here by default.
/webapps - This is where our webapps go.
Configuring Tomcat
This section will acquaint we with the basic information used during the
configuration of the container.
All of the information in the configuration files is read at startup, meaning that any
change to the files necessitates a restart of the container.
bin
conf
Lib
Logs
26 Webapp
Architecture of programmer’s application
Webapps
3.7 MYSQL
Yourapp.
MySQL is an SQL based relational database management system (DBMS) that
runs under a broad array of operating systems. MySQLimagesis frequently used by
Examples
PHP and Perl scripts. The SQL commands apply to MySQL operates under all
operating systems. Only the installation instructions are Windows specific. The
JSP
focus is on Windows XP Professional and Windows 2000 Professional machines.
SQL functions are implemented using a highly optimized class library and should
be as fast as possible. Usually there is no memory allocation at all after query
initialization. The MySQL code is tested with Purify (a commercial memory
leakage detector) as well as with Valgrind, a GPL tool.
27
Column Types
Full operator and function support in the SELECT and WHERE clauses of
queries. For example:
mysql> SELECT CONCAT(first_name, ' ', last_name)
FROM citizen
WHERE income/dependents > 10000 AND age > 30;
Full support for SQL GROUP BY and ORDER BY clauses. Support for
group functions (COUNT(), COUNT(DISTINCT ...), AVG(), STD(),
SUM(), MAX(), MIN(), and GROUP_CONCAT()).
Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with both
standard SQL and ODBC syntax.
Support for aliases on tables and columns as required by standard SQL.
DELETE, INSERT, REPLACE, and UPDATE return the number of rows that
were changed (affected). It is possible to return the number of rows
matched instead by setting a flag when connecting to the server.
The MySQL-specific SHOW command can be used to retrieve information
about databases, tables, and indexes. The EXPLAIN command can be
used to determine how the optimizer resolves a query.
Function names do not clash with table or column names. For example,
ABS is a valid column name. The only restriction is that for a function call,
no spaces are allowed between the function name and the `(' that
follows it.
We can mix tables from different databases in the same query (as of
MySQL 3.22).
Security
A privilege and password system that is very flexible and secure, and that allows
host-based verification. Passwords are secure because all password traffic is
encrypted when we connect to a server.
28
Up to 64 indexes per table are allowed (32 before MySQL 4.1.2). Each
index may consist of 1 to 16 columns or parts of columns. The maximum
index width is 1000 bytes (500 before MySQL 4.1.2). An index may use a
prefix of a column for CHAR, VARCHAR, BLOB, or TEXT column types.
Connectivity
Clients can connect to the MySQL server using TCP/IP sockets on any
platform. On Windows systems in the NT family (NT, 2000, or XP), clients
can connect using named pipes. On UNIX systems, clients can connect
using UNIX domain socket files.
The Connector/ODBC (MyODBC) interface provides MySQL support for
client programs that use ODBC (Open Database Connectivity)
connections. For example, we can use MS Access to connect to our
MySQL server. Clients can be run on Windows or UNIX. MyODBC source
is available. All ODBC 2.5 functions are supported, as are many others.
The Connector/J interface provides MySQL support for Java client
programs that use JDBC connections. Clients can be run on Windows or
Unix. Connector/J source is available.
Localization
The MySQL server has built-in support for SQL statements to check,
optimize, and repair tables. These statements are available from the
command line through the @command{mysqlcheck} client. MySQL also
includes @command{myisamchk}, a very fast command-line utility for
performing these operations on MyISAM tables.
All MySQL programs can be invoked with the --help or -? options to
obtain online assistance
29
3.7.2 Main Commands in MYSQL
A) CREATE Command
Or:
create_definition:
column_definition
| [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)
| KEY [index_name] [index_type] (index_col_name,...)
| INDEX [index_name] [index_type] (index_col_name,...)
| [CONSTRAINT [symbol]] UNIQUE [INDEX]
[index_name] [index_type] (index_col_name,...)
| [FULLTEXT|SPATIAL] [INDEX] [index_name] (index_col_name,...)
| [CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (index_col_name,...) [reference_definition]
| CHECK (expr)
30
column_definition:
col_name type [NOT NULL | NULL] [DEFAULT default_value]
[AUTO_INCREMENT] [[PRIMARY] KEY] [COMMENT 'string']
[reference_definition]
type:
TINYINT[(length)] [UNSIGNED] [ZEROFILL]
| SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
| MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
| INT[(length)] [UNSIGNED] [ZEROFILL]
| INTEGER[(length)] [UNSIGNED] [ZEROFILL]
| BIGINT[(length)] [UNSIGNED] [ZEROFILL]
| REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
| DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
| FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
| DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
| NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
| DATE
| TIME
| TIMESTAMP
| DATETIME
| CHAR(length) [BINARY | ASCII | UNICODE]
| VARCHAR(length) [BINARY]
| TINYBLOB
| BLOB
| MEDIUMBLOB
| LONGBLOB
| TINYTEXT
| TEXT
| MEDIUMTEXT
| LONGTEXT
| ENUM(value1,value2,value3,...)
| SET(value1,value2,value3,...)
| spatial_type
index_col_name:
col_name [(length)] [ASC | DESC]
reference_definition:
REFERENCES tbl_name [(index_col_name,...)]
[MATCH FULL | MATCH PARTIAL]
[ON DELETE reference_option]
[ON UPDATE reference_option]
reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
31
table_options: table_option [table_option] ...
table_option:
{ENGINE|TYPE} = {BDB|HEAP|ISAM|InnoDB|MERGE|MRG_MYISAM|
MYISAM}
| AUTO_INCREMENT = value
| AVG_ROW_LENGTH = value
| CHECKSUM = {0 | 1}
| COMMENT = 'string'
| MAX_ROWS = value
| MIN_ROWS = value
| PACK_KEYS = {0 | 1 | DEFAULT}
| PASSWORD = 'string'
| DELAY_KEY_WRITE = {0 | 1}
| ROW_FORMAT = { DEFAULT | DYNAMIC | FIXED | COMPRESSED }
| RAID_TYPE = { 1 | STRIPED | RAID0 }
RAID_CHUNKS = value
RAID_CHUNKSIZE = value
| UNION = (tbl_name[,tbl_name]...)
| INSERT_METHOD = { NO | FIRST | LAST }
| DATA DIRECTORY = 'absolute path to directory'
| INDEX DIRECTORY = 'absolute path to directory'
| [DEFAULT] CHARACTER SET charset_name [COLLATE collation_name]
B) SELECT Command
MySQL Server doesn't support the Sybase SQL extension: SELECT ... INTO
TABLE .... Instead, MySQL Server supports the standard SQL syntax INSERT
INTO ... SELECT ..., which is basically the same thing.
C) INSERT Command
Or:
32
SET col_name={expr | DEFAULT}, ...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
Or:
INSERT inserts new rows into an existing table. The INSERT ... VALUES and
INSERT ... SET forms of the statement insert rows based on explicitly specified
values. The INSERT ... SELECT form inserts rows selected from another table or
tables. The INSERT ... VALUES form with multiple value lists is supported in
MySQL 3.22.5 or later. The INSERT ... SET syntax is supported in MySQL
3.22.10 or later
tbl_name is the table into which rows should be inserted. The columns for which
the statement provides values can be specified as follows:
• The column name list or the SET clause indicates the columns explicitly.
• If we do not specify the column list for INSERT ... VALUES or INSERT ...
SELECT, values for every column in the table must be provided in the
VALUES() list or by the SELECT. If we don't know the order of the
columns in the table, use DESCRIBE tbl_name to find out.
D) UPDATE Command
Single-table syntax:
Multiple-table syntax:
The UPDATE statement updates columns in existing table rows with new values.
The SET clause indicates which columns to modify and the values they should
be given. The WHERE clause, if given, specifies which rows should be updated.
Otherwise, all rows are updated. If the ORDER BY clause is specified, the rows
33
will be updated in the order that is specified. The LIMIT clause places a limit on
the number of rows that can be updated.
3.9 JAVASCRIPT
34
Explorer
example:
<html>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
</html>
35
4.0 ABOUT PROJECT
File Splitter is designed to keep record of all the data of the DUF’s, i.e., (DAILY
USAGE FILES). These files are used by telecom companies. They keep the data
in numeric form, which shows the time taken by particular customer.
Main objective of this project is to fetch the data from the DUF’s and then store
them in a separate database. It also informs all the customers about the data on
their email id.
This project has been implemented to help in keeping data of all the customers
who are availing the services of United Telecom LLC company in New York. This
company uses the telecom server of Qwest company for all the proceedings.
Data from this server comes to United Telecom company in the form of DUF
(Daily Usage Files). These DUF’s contain the data in numeric form as these are
output from an electronic device. Therefore the foremost function of project is to
read all DUF’s . There is an ASCII* code file in which meaning of the sequence of
numbers from a particular location upto a particular location is defined. According
to data in ASCII file DUF is splitted and final data is sent to the email id of the
customer. File which contains all the details of the duration to which customer
has talked is called one Ani file. Each customer has more than one ani files. In
this project client is the distributed network, which works under the United LLC
company. They need data to be properly organized so that proper bill calculation
can be performed. Thus here a proper backend is also used which keeps all the
data of customer in the database. Main steps followed in the project preparation
are:
*ASCII file is attached in appendix with the source code and outptut of the
program
36
4.2 Main Packages and classes used:
a) Util package:
DAO Base: It is the main class in which all the functions related to the
database like creation, insertion, updation, deletion from the table takes
place.
DAO Constants: This is the interface which declares the basic variables
and is implemented by DAOBase class.
Session Objects: It declares all the session variables which may be used
during the session.
b) Exceptions:
37
EOException: It declares the exception for entity objects and extends the
Exception class.
ControlEO: In this class function splits the files and extracts the required
information about client.
TEOclient: It declares all the variables used in the client table. It also
inherits the DAOBase class.
f) servlets package:
38
InitServlet: It initializes all the variables declaring database username,
password, url and driverclass.
AddUserServlet: It takes all the details about the client like name, city,
country, companyname, emailed and send it add_client.jsp.
EditUserServlet: It takes all the details about the client like name, city,
country, companyname, emailed and send it to edit_client.jsp.
SQL Tables:
There are 4 tables:
1. ani_row_table: It contains details of ani.its main fields are:
id integer PrimaryKey autoincrement
ani_id integer
row_details longtext
39
ani_name varchar
1) DAOBase:
It performs all the SQL queries on the database entries. Its main
methods and their function:
public DAOBase()
This constructor should never be invoked from any DAO class. It has been
added to avoid compilation errors. It will throw an Assertion exception if
invoked implying that the keys have not been set. If there are no primary
keys in the table, then invoke the alternate constructor as
<code>super(new String[0])</code>
Identify the primaryKeys and also the table name. This is done in cases
where the table name does not match the DAO. @param tableName:
Send in null if the derived class name matches the table name (- the DAO
prefix) Otherwise send in the appropriate table name from the DAO.
Converts all the fields in the derived class to internal properties for efficient
access
Find the internal mapper corresponding to the column name (the attribute
of the class) specified as the parameter
ignores the attributes in any of the insert, update or read calls. Helpful
when the attributes in the table are far more than the attributes required.
40
public void setRequiredAttributes(String[] attributesToAdd)
adds the attributes in read calls. Helpful when the attributes in the table
are far more than the attributes required. If this call is not made, then all
attributes are included by default in a sql get.
Returns all the dao's appropriately initialized in an array. This code is for a
pass thru SQL Query, for cases where we need to get data based on a
custom sql query.
Tries to create a new row in the database. It initializes the primary key
after the insert in this object only. The call assumes that the primary keys
are not initialized and will be initialized after the call
Tries to update a row in the database on the basis of the key attributes
@param updateKeys The keys to be used for update (where clause in
update) @param primaryKeys The keys to be ignored in the set clause.
Tries to update a row in the database on the basis of the where clause.
the whereClause would help update multiple rows at the same time.
@param whereClause Gives the condition for updation.
41
public int count(Connection conn, String[] keys) throws
SQLException
Counts the no of rows that follow the conditions specified through the
where clause.
This method creates where clause for all CRUD functions in this class that
doesn’t provide prebuilt whereClause.
This class maps the fields for a DAO to the appropriate datatypes and
provides methods such that these can be used in SQL strings. At the
same time it allows the setting of the field from the result set object. Allows
efficiency by mapping class fields just once in their lifetime.
Set the attribute for the dao object based on the resultSet results
42
Returns the name=value in appropriate sql format. For eg, for dates and
strings it is appropriately quoted and for booleans also it is converted
appropriately Will be used in the where clause or the insert / update
clause
2) ControlEO :
There is only one method in this class and it performs the splitting of files
according the position of numbers in the files. Meaning of particular
position is read from the ASCII file. Thus it uses the substring function to
split the file.
These are the two major and most important classes which perform the
major functions.
43
REFERENCES
ADDRESSES
71 Storm Street, 4A
Tarrytown, NY 10591 USA
info@planetwire.net
Fax: 516-487-5692
Address:175,GREATNECKROAD
Suite404
Great Neck, NY 11021
44
APPENDIX – A
PROJECT CODE:
1) CLASSES
Util package:
Assert
package planetwire.splitter.util;
public class Assert {
public Assert() {
}
AssertionException
package planetwire.splitter.util;
public class AssertionException extends RuntimeException {
public AssertionException(String msg){
super(msg);
}
45
}
DAOBase
package planetwire.splitter.util;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Hashtable;
import java.util.Vector;
/**
* All the field names are mapped to properties for easier access
*/
PropertyMapper[] arPropertyMapper = null;
/**
* The attributes that should be ignored during a read, insert or update
* @see ignoreAttributes
*/
private String[] attributesToIgnore;
/**
* The name of the table which the DAO links to. In the future this can be made a view
* on the database. Let's see how successful the DAO class structure is
*/
private String tableName;
46
/**
* This constructor should never be invoked from any DAO class. It has been added to
* avoid compilation errors. It will throw an Assertion exception if invoked
* implying that the keys have not been set. If there are no primary keys
* in the table, then invoke the alternate constructor as
* <code>super(new String[0])</code>
*/
public DAOBase(){
this(null);
}
Class.forName(driverClass);
connection = DriverManager.getConnection(dbURL,
dbUser, dbPassword);
} catch(Exception ex)
{
ex.printStackTrace();
Assert.assertNull(connection, "The database connection
is currently unavailable.");
}
}
return connection;
}
}
47
}
/**
* Identify the primaryKeys and also the table name. This is done in cases
* where the table name does not match the DAO.
* @param tableName: Send in null if the derived class name matches the table name (-
the DAO prefix)
* Otherwise send in the appropriate table name from the DAO.
*/
public DAOBase(String tableName){
if(tableName != null)
this.tableName = tableName.toUpperCase();
else {
String className = getClass().getName();
int index = className.lastIndexOf('.');
className = className.substring(index + 1);
Assert.assertFalse(className.startsWith(CLASS_PREFIX),
"Don't know how to derive the table name from the class=" +
className);
this.tableName = className.substring(3).toUpperCase(); // gives the
class name after the dao
}
mapProperties();
//debug();
}
/**
* Converts all the fields in the derived class to internal properties for efficient access
*/
private void mapProperties(){
Field[] fields = super.getClass().getDeclaredFields();
arPropertyMapper = (PropertyMapper[])propertyMap.get(getClass().getName());
if(arPropertyMapper == null) {
arPropertyMapper = new PropertyMapper[fields.length];
PropertyMapper elem;
for(int i = 0; i < fields.length; i++){
if(INDEX_MAPPING)
elem = new PropertyMapper(fields[i], i);
else
elem = new PropertyMapper(fields[i]);
arPropertyMapper[i] = elem;
}
propertyMap.put(getClass().getName(), arPropertyMapper);
}
//System.out.println("the no of keys::"+propertyMap.size());
}
/**
* Returns true if the property is a key in the current operation
*/
private boolean isKey(String[] keys, PropertyMapper property){
for(int i = 0; i < keys.length; i++)
if(keys[i].equalsIgnoreCase(property.name))
return true;
return false;
}
48
/**
* Find the internal mapper corresponding to the column name (the attribute of the class)
* specified as the parameter
*/
private PropertyMapper findMapper(String columnName){
for(int i = 0; i < arPropertyMapper.length; i++)
if(arPropertyMapper[i].name.equalsIgnoreCase(columnName))
return arPropertyMapper[i];
return null;
}
/**
* ignores the attributes in any of the insert, update or read calls. Helpful when the
* attributes in the table are far more than the attributes required.
*/
public void ignoreAttributes(String[] attributesToIgnore){
this.attributesToIgnore = attributesToIgnore;
}
/**
* adds the attributes in read calls. Helpful when the
* attributes in the table are far more than the attributes required.
* If this call is not made, then all attributes are included by default in a sql get
*/
ignoreAttrib.addElement(arPropertyMapper[i].name);
}
}
String[] attributesToIgnore = new String[ignoreAttrib.size()];
//System.out.println("ignoreAttrib"+ignoreAttrib);
ignoreAttrib.copyInto(attributesToIgnore);
// make the call to ignore the attributes
ignoreAttributes(attributesToIgnore);
}
49
/**
* Returns true if the attribute is to be ignored
*/
private boolean isAttributeIgnored(String attribName){
if(attributesToIgnore == null)
return false;
for(int i = 0; i < attributesToIgnore.length; i++)
if(attributesToIgnore[i].equalsIgnoreCase(attribName))
return true;
return false;
}
/**
* Returns all the dao's appropriately initialized in an array. It is assumed that
* all the keys are appropriately initialized
* Returns all the results appropriately initialized on the basis of the keys supplied
* as the parameer
*
* The code can be executes as follows:
* <code>DAOMyTable dao = new DAOMyTable();
* dao.property1 = <some value>
* dao.property2 = <some other value>;
* String keys[] = {"property1", "property2"};
* DAOMyTable[] daos= dao.readAll(MyConnectionManager.getConnection(), keys);
* if(daos.length > 0) {// record(s) have been found
* .
* .
* }else{ // no record has been found
* .
* .
* }</code>
*
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*
*/
public DAOBase[] readAll(Connection conn, String[] keys)
throws SQLException {
Connection connOnParameter = conn;
try
{
50
}
}
}
sql.append(" FROM " + tableName);
String whereClause = createWhereClause(keys);
sql.append(whereClause);
System.out.println("SQL String is " + sql.toString());
//System.out.println("SELECT QUERY:"+sql.toString());
// create a new instance of
while(results.next()){
DAOBase newObject =
(DAOBase)objClass.newInstance();
for(int i = 0; i < arPropertyMapper.length; i++)
if(!isAttributeIgnored(arPropertyMapper[i].name))
arPropertyMapper[i].initializeDaoAttribute(newObject, results);
vec.add(newObject);
}
st.close();
DAOBase[] resultAr = new DAOBase[vec.size()];
vec.copyInto(resultAr);
return resultAr;
} catch(IllegalAccessException il)
{
il.printStackTrace();
}catch (InstantiationException ex)
{
ex.printStackTrace();
}
finally{
if(connOnParameter == null) // a connection has been obtained
releaseConnection(conn);
}
return new DAOBase[0];
}
/**
* Returns all the dao's appropriately initialized in an array.
* This code is for a pass thru SQL Query, for cases where we need to
* get data based on a custom sql query.
*
* The code can be executes as follows:
* <code>DAOMyTable dao = new DAOMyTable();
* String WHERE = "attribute1 LIKE "" AND attribute2 BETWEEN date1 and date2";
* DAOMyTable[] daos= dao.readAll(MyConnectionManager.getConnection(), WHERE);
* if(daos.length > 0) {// record(s) have been found
51
* .
* .
* }else{ // no record has been found
* .
* .
* }</code>
*
*
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
public DAOBase[] readAll(Connection conn, String whereClause)
throws SQLException {
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("SELECT ");
boolean foundFirst = false;
if(attributesToIgnore == null)
sql.append("*");
else{
for(int i = 0; i < arPropertyMapper.length; i++){
if(!isAttributeIgnored(arPropertyMapper[i].name))
{
if(foundFirst)
sql.append(",");
else
foundFirst = true;
sql.append(arPropertyMapper[i].name);
}
}
}
sql.append(" FROM " + tableName);
if (!whereClause.equals(""))
{
52
arPropertyMapper[i].initializeDaoAttribute(newObject, results);
vec.add(newObject);
}
st.close();
DAOBase[] resultAr = new DAOBase[vec.size()];
vec.copyInto(resultAr);
return resultAr;
} catch(IllegalAccessException il)
{
il.printStackTrace();
}catch (InstantiationException ex)
{
ex.printStackTrace();
}finally{
if(connOnParameter == null) // a new connection was allotted
releaseConnection(conn);
}
return new DAOBase[0];
}
try
{
StringBuffer sql = new StringBuffer("SELECT ");
//sql.append(Distinct_key);
}
else{
sql.append("DISTINCT ");
for(int i = 0; i < arPropertyMapper.length; i++){
if(!
isAttributeIgnored(arPropertyMapper[i].name)){
if(foundFirst)
sql.append(",");
else
foundFirst = true;
sql.append(arPropertyMapper[i].name);
}
}
}
sql.append(" FROM " + tableName);
if (!whereClause.equals(""))
{
53
System.out.println("SQL String is " + sql.toString());
// stmt is created. Now we execute it and initialize the
results.
if (conn==null)
conn = getConnection();
Vector vec = new Vector();
Class objClass = getClass();
Statement st = conn.createStatement();
// run the database query
int j=0;
vec.add(results.getString(1));
j++;
}
String[] resultAr = new String[j];
st.close();
vec.copyInto(resultAr);
for(int i=0;i<resultAr.length;i++)
System.out.println(resultAr[i]);
return resultAr;
} catch (Exception ex)
{
ex.printStackTrace();
}finally{
if(connOnParameter == null) // a new connection was
allotted
releaseConnection(conn);
}
return new String[0];
}
try
{
StringBuffer sql = new StringBuffer("SELECT ");
boolean foundFirst = false;
if(attributesToIgnore == null)
{
sql.append("*");
}
else{
for(int i = 0; i <
arPropertyMapper.length; i++){
if(!
isAttributeIgnored(arPropertyMapper[i].name)){
54
if(foundFirst)
sql.append(",");
else
foundFirst =
true;
sql.append(arPropertyMapper[i].name);
}
}
}
sql.append(" FROM " + tableName);
if (!whereClause.equals(""))
{
arPropertyMapper[i].initializeDaoAttribute(newObject, results);
vec.add(newObject);
}
st.close();
DAOBase[] resultAr = new DAOBase[vec.size()];
vec.copyInto(resultAr);
return resultAr;
} catch(IllegalAccessException il)
{
il.printStackTrace();
}catch (InstantiationException ex)
{
ex.printStackTrace();
}finally{
55
if(connOnParameter == null) // a new connection
was allotted
releaseConnection(conn);
}
return new DAOBase[0];
}
/**
* Tries to create a new row in the database. It initializes the primary key after the insert
* in this object only. The call assumes that the primary keys are not initialized and will
* be initialized after the call
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
public int create(Connection conn) throws SQLException {
// create the statement
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("INSERT INTO " +
tableName);
StringBuffer names = new StringBuffer(), values= new
StringBuffer();
boolean firstFound = false;
for(int i = 0; i < arPropertyMapper.length; i++){
PropertyMapper mapper = arPropertyMapper[i];
if(isAttributeIgnored(mapper.name))
continue;
if(firstFound){
names.append(",");
values.append(",");
}
names.append(mapper.name);
values.append(mapper.getValue(this));
if(!firstFound)
firstFound = true;
}
sql.append(" (").append(names.toString()).append(") VALUES
(").append(values.toString()).append(")");
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql.toString());
// ------------------------------------------------------
// get the new identity row -- specific for SQL Server
//java.util.Vector vec = new java.util.Vector();
//Class objClass = getClass();
// run the database query
Statement st = conn.createStatement();
56
// System.out.println("---------Before----------------");
// int pkey = -1;
// while (rowId.next())
// pkey = rowId.getInt("PKEY");
// return pkey;
// //-------------------------------------------------------
// TODO to check how to get the value of the primary keys and to
initialize them
// in the current class.
//conn.commit();
} catch(IllegalAccessException il){
il.printStackTrace();
}finally{
if(connOnParameter == null) // conn would have been allocated in this
method.
releaseConnection(conn);
}
return -1;
}
/**
* Tries to create a new row in the database. It initializes the primary key after the insert
* in this object only. The call assumes that the primary keys are not initialized and will
* be initialized after the call Returns the pkey after
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
/*public int createPrimary(Connection conn, String[] primaryKeys) throws SQLException{
// create the statement
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("INSERT INTO " +
tableName);
StringBuffer names = new StringBuffer(), values= new
StringBuffer();
boolean firstFound = false;
for(int i = 0; i < arPropertyMapper.length; i++){
PropertyMapper mapper = arPropertyMapper[i];
if(isAttributeIgnored(mapper.name) || isKey(primaryKeys,
mapper))
continue;
if(firstFound){
names.append(",");
values.append(",");
}
names.append(mapper.name);
values.append(mapper.getValue(this));
if(!firstFound)
firstFound = true;
}
sql.append(" (").append(names.toString()).append(") VALUES
(").append(values.toString()).append(")");
System.out.println(sql.toString());
57
if (conn==null)
conn = getConnection();
CallableStatement stmt = conn.prepareCall("{call
insertNewRow(?,?)}"); //prepares the call
//setting the values to be passed
stmt.setString(1,sql.toString());
stmt.registerOutParameter(2, Types.INTEGER);
//TODO - tb - make sure somehow(!!!!) that this code works and
actually
// synchronizes the stored procedure call.
synchronized(DAOBase.class){
stmt.execute(); //executes the procedure
}
int retVal = stmt.getInt(2);
return retVal;
//-------------------------------------------------------
// TODO to check how to get the value of the primary keys and to
initialize them
// in the current class
} catch(IllegalAccessException il)
{
new saigun.pms.util.ErrorLogger("Illegal Access Exception", il);
}finally{
if(connOnParameter == null) // conn setup in this method
releaseConnection(conn);
}
return -1;
}
*/
/**
* Tries to update a row in the database on the basis of the key attributes
* @param updateKeys The keys to be used for update (where clause in update)
* @param primaryKeys The keys to be ignored in the set clause.
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
public void update(Connection conn, String[] updateKeys, String[] primaryKeys) throws
SQLException{
// create the statement
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("UPDATE " + tableName + "
SET ");
// create the set clause
StringBuffer values= new StringBuffer();
boolean firstFound = false;
for(int i = 0; i < updateKeys.length; i++){
PropertyMapper mapper = findMapper(updateKeys[i]);
Assert.assertNull(mapper, "Mapper could not be
obtained for the key=" + updateKeys[i]);
if(isAttributeIgnored(mapper.name) || isKey(primaryKeys,
mapper)) // a primary key cannot be updated
continue;
if(firstFound)
58
values.append(",");
values.append(mapper.getSQLString(this, false));
if(!firstFound)
firstFound = true;
}
sql.append(values.toString()).append("");
values = new StringBuffer();
firstFound = false;
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql.toString());
//conn.commit();
} catch(IllegalAccessException il)
{
il.printStackTrace();
}finally{
if(connOnParameter == null) // the connection was created in this method
releaseConnection(conn);
}
}
59
if(!firstFound)
firstFound = true;
}
sql.append(values.toString());
sql.append(" WHERE ").append(whereClause);
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
Statement stmt = conn.createStatement();
//System.out.println(sql);
stmt.executeUpdate(sql.toString());
//conn.commit();
} catch(IllegalAccessException il) {
il.printStackTrace();
}finally{
if(connOnParameter == null) // the connection was created in this method
releaseConnection(conn);
}
}
/**
* Deletes on the basis of the values of the primary keys
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
public void delete(Connection conn, String[] keys) throws SQLException {
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("DELETE FROM " +
tableName);
String whereClause = createWhereClause(keys);
sql.append(whereClause);
System.out.println(sql.toString());
if (conn == null)
conn = getConnection();
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql.toString());
//conn.commit();
}catch(IllegalAccessException il)
{
il.printStackTrace();
}finally{
if(connOnParameter == null)
releaseConnection(conn);
}
}
/**
* Counts the no of rows that follow a particular criteria
60
*/
public int count(Connection conn, String[] keys) throws SQLException {
int count = -1;
Connection connOnParameter = conn;
try {
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM " +
tableName);
String whereClause = createWhereClause(keys);
sql.append(whereClause);
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
results.close();
stmt.close();
} catch(IllegalAccessException il) {
il.printStackTrace();
}finally {
if(connOnParameter == null) // a new connection was allotted
releaseConnection(conn);
}
return count;
}
/**
* Counts the no of rows that follow the conditions specified through
* the where clause.
*/
public int count(Connection conn, String whereClause) throws SQLException {
int count = -1;
Connection connOnParameter = conn;
try{
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM " +
tableName);
sql.append(" WHERE ").append(whereClause);
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
61
}
results.close();
stmt.close();
}catch(SQLException sqle) {
throw new SQLException();
}finally {
if(connOnParameter == null) // a new connection was allotted
releaseConnection(conn);
}
return count;
}
/**
* This method creates where clause for all CRUD functions in this class that don't
provide
* prebuilt whereClause.
*/
private String createWhereClause(String[] keys) throws IllegalAccessException {
StringBuffer values = new StringBuffer();
boolean firstFound = false;
for(int i = 0; i < keys.length; i++) {
if(firstFound)
values.append(" AND ");
// if(isAttributeIgnored(keys[i]))
// continue;
PropertyMapper mapper = findMapper(keys[i]);
Assert.assertNull(mapper, "The mapper not available for table name="+
tableName +" and key="+keys[i]);
values.append(mapper.getSQLString(this, true));
if(!firstFound)
firstFound = true;
}
if(values.length() > 0)
return " WHERE " + values.toString();
else
return "";
}
/**
* Deletes on the basis of the values of the where clause specified
* @param conn Pass a valid connection object if this call is a part of a transaction
* updating multiple tables. Otherwise we should set this parameter to null.
*/
public void delete(Connection conn,
//String[
] keys,
String
whereClause) throws SQLException {
Connection connOnParameter = conn;
try
{
StringBuffer sql = new StringBuffer("DELETE FROM " +
tableName), values;
values = new StringBuffer();
62
boolean firstFound = false;
System.out.println(sql.toString());
if (conn==null)
conn = getConnection();
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql.toString());
}catch(Exception il)
{
il.printStackTrace();
}finally{
if(connOnParameter == null)
releaseConnection(conn);
}
}
}
/**
* This class maps the fields for a DAO to the appropriate datatypes and provides
* methods such that these can be used in SQL strings. At the same time it allows the
* setting of the field from the result set object. Allows efficiency by mapping class
* fields just once in their lifetime.
*
*/
class PropertyMapper implements DAOConstants{
private static final int STRING_CLASS = 100;
private static final int CHAR_CLASS = 101;
String name;
int typeId;
int index;
Field field;
/**
* Initializes the PropertyMapper by using the field passed in.
* @param field. The field that is being used in the property mapper
* @param index. The index of the field in the table. This is with the expectation
* that java will return the fields in the same order as the cols in the database and
* that is based on the creation strategy in the table.
63
* to true to manage the primary keys.
*/
PropertyMapper(Field field, int index){
this.field = field;
name = field.getName().toUpperCase();
Class fieldClass = field.getType();
// identify the type of the field for use later
if(fieldClass == String.class)
typeId = STRING_CLASS;
else if(fieldClass == Integer.TYPE)
typeId = INTEGER_CLASS;
else if(fieldClass == Boolean.TYPE)
typeId = BOOLEAN_CLASS;
else if(fieldClass == Short.TYPE)
typeId = SHORT_CLASS;
else if(fieldClass == Float.TYPE)
typeId = FLOAT_CLASS;
else if(fieldClass == Double.TYPE)
typeId = DOUBLE_CLASS;
else if(fieldClass == java.util.Date.class || fieldClass ==
java.sql.Date.class)
typeId = DATE_CLASS;
else if(fieldClass == Character.TYPE)
typeId = CHAR_CLASS;
else
Assert.assertFalse(false, "The class of type " +
fieldClass.getName() + " for the field " + name + " has not been mapped to a reconizable
type. FIX this problem.");
}
/**
* If DAO's are mapped according to indexes then call the other method
*/
PropertyMapper(Field field){
this(field, -1);
}
/**
* Set the attribute for the dao object based on the resultSet results
*/
void initializeDaoAttribute(Object dao, ResultSet result)
throws SQLException, IllegalAccessException{
Object value;
if(index > 0)
value = result.getObject(index);
else
value = result.getObject(name);
setValue(dao, value);
}
/**
* Returns the name=value in appropriate sql format. For eg, for dates and strings
* it is appropriately quoted and for booleans also it is converted appropriately
* Will be used in the where clause or the insert / update clause
*/
String getSQLString(Object dao, boolean whereClause) throws IllegalAccessException{
String sql = name;
64
String value = getValue(dao);
String equalsClause = ((value == null || value.equalsIgnoreCase("null")) &&
whereClause)?
" IS " : "=";
return sql + equalsClause + value;
}
65
return (value != null && ((Long)value).longValue() !=
NULL_LONG)?
value.toString() : "null";
case FLOAT_CLASS:
return (value != null && ((Float)value).floatValue() !=
NULL_FLOAT)?
value.toString() : "null";
case DOUBLE_CLASS:
return (value != null && ((Double)value).intValue() !=
NULL_DOUBLE)?
value.toString() : "null";
default:
Assert.assertFalse(false, "Method to convert name=" + name + "
in dao not found");
}
return "";
}
66
if(val == null)val = new Long(NULL_LONG);
break;
case DOUBLE_CLASS:
if(val == null)val = new Double(NULL_DOUBLE);
break;
default:
// nothing to be done here
}
field.set(obj, val);
}
DAOConstants
package planetwire.splitter.util;
public interface DAOConstants {
public static int NULL_INT = Integer.MIN_VALUE;
public static boolean NULL_BOOLEAN = false;
public static short NULL_SHORT = Short.MIN_VALUE;
public static float NULL_FLOAT = Float.MIN_VALUE;
public static double NULL_DOUBLE = Double.MIN_VALUE;
public static String NULL_STRING = null;
public static long NULL_LONG = Long.MIN_VALUE;
// The quote character may change over the databases, hence a constant
public static String QUOTE_CHAR = "'";
// The prefix for all the dao classes generated corresponding to the database schema
public static String CLASS_PREFIX = "TEO";
SessionObjecs
package planetwire.splitter.util;
67
public static final String MSG_DESIRE = "MSG_DESIRE";
public static final String MSG_SENT = "MSG_SENT";
public static final String TEMP = "TEMP";
//Holds Login UserTEO
}
ao package
AOFactory
package planetwire.splitter.ao;
import planetwire.splitter.util.Assert;
private AOFactory() {
}
BaseAO
package planetwire.splitter.ao;
CustomerAO
package planetwire.splitter.ao;
68
import planetwire.splitter.eo.CustomerEO;
import planetwire.splitter.eo.EOFactory;
import planetwire.splitter.exception.AOException;
import planetwire.splitter.exception.EOException;
import planetwire.splitter.teo.TEOclient;
eo package
BaseEO
package planetwire.splitter.eo;
CustomerEO
package planetwire.splitter.eo;
import planetwire.splitter.exception.EOException;
import planetwire.splitter.util.DAOBase;
public CustomerEO() {
}
}
EOFactory
package planetwire.splitter.eo;
69
import planetwire.splitter.util.Assert;
private EOFactory() {
}
HelperEO
package planetwire.splitter.eo;
protected HelperEO() {
}
}
ControlEO
package planetwire.splitter.eo;
import java.io.*;
import java.util.*;
import planetwire.splitter.teo.TEOani_row_table;
import planetwire.splitter.teo.TEOunique_ani_temp;
import planetwire.splitter.util.DAOBase;
public ControlEO() {
70
}
public void getSplit(String filename)
{
int i=0,j=0,k=0;
Vector temp = new Vector(10,1);
String arr[] = null;
int verify = 0;
String[][] arr1 =null;
try{
BufferedReader file = new BufferedReader(new FileReader(filename));
String line;
file.readLine();
String match = "";
while(((line=file.readLine()) != null))
{
if(line.length()>23)
match = line.substring(14,24);
if(i==0)
{
temp.add(match);
arr = new String[temp.size()];
temp.toArray(arr);
//System.out.println(line);
//arr[0] = match;
k++;
i++;
continue;
}
if(k>0)
{
//System.out.println("l"+arr.length);
verify=0;
for(j=0;j<arr.length;j++)
{
if(match.equals(arr[j]))
{
verify=1;
break;
}
else
{
//arr[k] = match;
//temp.add(match);
continue;
}
}
if(verify==0)
temp.add(match);
//arr=null;
}
arr = null;
71
arr = new String[temp.size()];
temp.toArray(arr);
/*System.out.println("\ni="+i);
System.out.println("\nline="+line);*/
k++;
i++;
}
file = new BufferedReader(new FileReader(filename));
arr1 = new String[arr.length-1][];
int arr2[] = new int[arr.length-1];
TEOunique_ani_temp anis = new TEOunique_ani_temp();
anis.delete(null,"1");
for(i=0;i<arr.length-1;i++)
{
arr2[i] = 0;
arr1[i] = new String[110];
anis.ani_id = i+1;
anis.ani_name = arr[i];
anis.create(null);
}
TEOunique_ani_temp[] ani_list = null;
DAOBase[] ar =null;
ar = anis.readAll(null,"");
if(ar.length!=0)
{
ani_list = new TEOunique_ani_temp[ar.length];
System.arraycopy(ar,0,ani_list,0,ar.length);
}
}
// System.out.println("l"+arr.length);
for(i=0;i<arr.length;i++)
{
//System.out.println("\n"+arr[i]);
72
}
// System.out.println("rohit");
// System.out.println(line);
/*for(i=0;arr1[90][i]!=null;i++)
System.out.println(arr1[90][i]);*/
}
catch(Exception e)
{
System.out.println(e.toString());
}
exception package
AOException
package planetwire.splitter.exception;
public AOException() {
}
EOException
package planetwire.splitter.exception;
teo package
TEOani_row_table
package planetwire.splitter.teo;
73
import planetwire.splitter.util.DAOBase;
public TEOani_row_table() {
}
}
TEOclient
package planetwire.splitter.teo;
import planetwire.splitter.util.DAOBase;
public TEOclient() {
}
}
TEOclient_ani_details
package planetwire.splitter.teo;
import planetwire.splitter.util.DAOBase;
public TEOclient_ani_details() {
}
}
TEOunique_ani_temp
74
package planetwire.splitter.teo;
import planetwire.splitter.util.DAOBase;
public TEOunique_ani_temp() {
}
}
servlets package
AddUserServlet
package planetwire.splitter.servlets;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
//import java.util.*;
import planetwire.splitter.teo.TEOclient;
import planetwire.splitter.teo.TEOclient_ani_details;
import planetwire.splitter.util.DAOBase;
75
String email = request.getParameter("email");
try
{
TEOclient customer = new TEOclient();
DAOBase[] ar = null;
String where = "";
String url = "";
String send = "";
where = "client_name='"+user+"'";
ar = customer.readAll(null,where);
if(ar.length!=0)
{
url="../jsp/add_client.jsp?
a=1&mode=1&user="+user+"&company="+company+"&anis="+anis+"&country="+country+"
&city="+city+"&email="+email;
send = response.encodeRedirectURL(url);
response.sendRedirect(send);
}
else
{
customer.client_name = user;
customer.client_city = city;
customer.country = country;
customer.company_name = company;
customer.client_emailid = email;
customer.create(null);
ani.client_id = client_list[0].client_id;
ani.ani_info = anis[i];
ani.create(null);
}
url= "../jsp/add_client.jsp?a=1&mode=2";
send = response.encodeRedirectURL(url);
response.sendRedirect(send);
}
}catch(Exception e){
e.printStackTrace();
}
}
}
EditUserServlet
package planetwire.splitter.servlets;
import java.io.IOException;
76
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import planetwire.splitter.teo.TEOclient;
import planetwire.splitter.teo.TEOclient_ani_details;
import planetwire.splitter.util.DAOBase;
ar = customer.readAll(null,where);
if(ar.length!=0)
{
TEOclient[] client_list = new TEOclient[ar.length];
System.arraycopy(ar,0,client_list,0,ar.length);
for(i=0;i<client_list.length;i++)
{
if(user.equals(client_list[i].client_name))
{
url="../jsp/edit_client.jsp?
a=2&mode=1&user="+user+"&company="+company+"&country="+country+"&city="+city+"&e
mail="+email+"&client="+client_id;
for (i=0;i<anis.length;i++)
url+="&anis="+anis[i];
77
send=response.encodeRedirectURL(url);
response.sendRedirect(send);
}
}
}
else
{
customer.client_name = user;
customer.client_city = city;
customer.country = country;
customer.company_name = company;
customer.client_emailid = email;
where = "client_id="+client_id;
String[] up_keys
={"client_name","client_city","country","company_name","client_emailid"};
String[] pri_keys ={""};
customer.update(null,up_keys,pri_keys,where);
TEOclient_ani_details ani = new TEOclient_ani_details();
ani.delete(null,where);
for(i=0;i<anis.length;i++)
{
ani.client_id = Integer.parseInt(client_id);
ani.ani_info = anis[i];
ani.create(null);
}
url= "../jsp/edit_client.jsp?a=2&mode=2";
send = response.encodeRedirectURL(url);
response.sendRedirect(send);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Initservlet
package planetwire.splitter.servlets;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import planetwire.splitter.util.DAOBase;
78
public void init(ServletConfig config) throws ServletException{
super.init(config);
String dbUserName = getInitParameter("splitter_app.dbUser"),
dbPassword =
getInitParameter("splitter_app.dbPassword"),
dbURL =
getInitParameter("splitter_app.dbURL"),
driverClass =
getInitParameter("splitter_app.driverClass");
DAOBase.dbPassword = dbPassword;
DAOBase.dbURL = dbURL;
DAOBase.dbUser = dbUserName;
DAOBase.driverClass = driverClass;
}
response.sendRedirect("../jsp/index.html");
}
}
SplitterServlet
package planetwire.splitter.servlets;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.*;
import com.oreilly.servlet.MultipartRequest;
import planetwire.splitter.eo.ControlEO;
79
try {
MultipartRequest multi =
new MultipartRequest(req, "C:/Jakarta/webapps/splitter_app/Uploads/", 5 *
1024 * 1024);
2)JSP FILES
add_client
<%
try
{
request.getSession(true);
String mode= request.getParameter("mode");
80
int i=0,j=0;
String client_anis=null;
String name="";
String city="";
String company="";
String country="";
String email="";
String where ="";
TEOunique_ani_temp ani_temp = new TEOunique_ani_temp();
TEOunique_ani_temp[] ani_list = null;
DAOBase[] ar_ani =null;
// Added by Rohit for Giving list of ANI other than of user on 9 Apr
TEOclient temp_cl = new TEOclient();
TEOclient[] tmp_cl_list = null;
ar_ani = temp_cl.readAll(null,"");
if(ar_ani.length!=0)
{
tmp_cl_list = new TEOclient[ar_ani.length];
System.arraycopy(ar_ani,0,tmp_cl_list,0,ar_ani.length);
for(j=0;j<tmp_de_list.length;j++)
{
if(j==tmp_de_list.length-1 && i==tmp_cl_list.length-1)
{
where +=tmp_de_list[j].ani_info;
}
else
{
where +=tmp_de_list[j].ani_info+",";
}
}
}
}
where +=")";
}
// End of Added by Rohit for Giving list of ANI other than of user on 9 Apr
ar_ani = ani_temp.readAll(null,where);
if(ar_ani.length!=0)
{
ani_list = new TEOunique_ani_temp[ar_ani.length];
81
System.arraycopy(ar_ani,0,ani_list,0,ar_ani.length);
}
%>
<script language="javascript">
function validate()
{
if(document.split.name.value=="")
{
alert("Enter the name of the Client");
document.split.name.focus();
return false;
}
else if(document.split.company.value=="")
{
alert("Enter the Company name of the Client");
document.split.company.focus();
return false;
}
else if(document.split.email.value=="")
{
alert("Enter the Email ID of the Client");
document.split.email.focus();
return false;
}
else if (checkemail()==false)
{
document.split.email.focus();
document.split.email.select();
return false;
}
else if(document.split.city.value=="")
{
alert("Enter the City name of the Client");
document.split.city.focus();
return false;
}
else if(document.split.country.value=="")
{
alert("Enter the Country name of the Client");
document.split.country.focus();
return false;
}
else if(document.split.anis.value==null || document.split.anis.value=="")
{
alert("We have to select atleast 1 ANI for the Client");
document.split.anis.focus();
return false;
}
else
{
document.split.action="http://localhost:8080/splitter_app/servlet/addClient";
document.split.submit();
82
}
function checkemail()
{
var testresults;
var str=document.split.email.value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true;
else
{
alert("Please enter a valid email address!");
testresults=false;
}
return (testresults)
}
</script>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400"
style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="top">
<table bgcolor=’#0000FF’>
<tr>
<td>
<tr>
83
<td width="43" height="23"> </td>
</tr>
<tr>
<td width="58" height="33"></td>
</center>
<td width="475" height="33" style="border-bottom-style: solid; border-bottom-color:
#1AD8E1" colspan="3" >
<p align="center"><b><font color="#000099" size="4" face="Verdana">ADD
CLIENT PAGE</font></b></p>
</td>
<td width="43" height="33"> </td>
</tr>
<center>
<%
if(mode.equals("1"))
{
name = request.getParameter("user");
city = request.getParameter("city");
company = request.getParameter("company");
country = request.getParameter("country");
email = request.getParameter("email");
%>
<tr>
<td width="58" height="54"></td>
<td width="53" height="54"></td>
<td colspan='2' align='center' height="54"><font color='#FF0000' face='Verdana'>
<b>
The Client Name we entered already exists<br> Please try again with new Client
Name</b></font></td>
<td width="43" height="54"> </td>
<%
}
else if(mode.equals("2"))
{
%>
<tr>
<td width="58" height="54"></td>
<td width="53" height="54"></td>
<td colspan='2' align='center' height="54"><font color='#FF0000' face='Verdana'>
<b>
The Client Creation process was done Successfully<br> To Create other Client fill all
details below</b></font></td>
<td width="43" height="54"> </td>
<%
}
%>
<tr>
<form name="split" method="post">
<td width="58" height="76"></td>
<td width="53" height="76" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="76" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Name
84
of Client : </font> </td>
<td width="232" height="76" valign="bottom"><input type="text" name="name" size="20"
tabindex="1" value="<%=name%>"> </td>
<td width="43" height="76"> </td>
</tr>
<tr>
<td width="58" height="33"></td>
<td width="53" height="33" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="33" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Company
of Client : </font> </td>
<td width="232" height="33" valign="bottom"><input type="text" name="company"
size="20" tabindex="2" value="<%=company%>"> </td>
<td width="43" height="33"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> </td>
<td width="197" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Email
ID of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="email" size="20"
tabindex="3" value="<%=email%>"> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="31"></td>
<td width="53" height="31" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="31" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">City
of Client : </font> </td>
<td width="232" height="31" valign="bottom"><input type="text" name="city" size="20"
tabindex="4" value="<%=city%>"> </td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> <font size="3" face="Verdana">
</font> </td>
<td width="197" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Country
of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="country"
size="20" tabindex="5" value="<%=country%>"> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="91"></td>
<td width="53" height="91" valign="bottom"> </td>
<td width="197" height="91" valign="middle" align="right"><font size="3" face="Verdana"
color="#0000FF">Add
ANIs to Client : </font> </td>
85
<td width="232" height="91" valign="bottom"><select name='anis' multiple size='4'
tabindex="6">
<%
if(ani_list!=null)
{
for(i=0;i<ani_list.length;i++)
{
%>
<option value="<%=ani_list[i].ani_name%>">
<%=ani_list[i].ani_name%> </option>
<%
}
}
%>
</select>
<br><font size='1' face='Verdana' color='#000000'> Use CTRL key to select Multiple
ANI</font>
</td>
</table>
</center>
</td></tr>
</table>
</td></tr>
</table>
<%
}// try
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
</html>
edit_client
86
planetwire.splitter.util.DAOBase,
java.util.*,
planetwire.splitter.teo.TEOunique_ani_temp" %>
<%
try
{
request.getSession(true);
TEOclient customer = new TEOclient();
TEOclient customer1 = new TEOclient();
TEOclient_ani_details ani = new TEOclient_ani_details();
TEOunique_ani_temp ani_temp = new TEOunique_ani_temp();
TEOunique_ani_temp[] ani_list = null;
TEOclient_ani_details[] client_ani = null;
TEOclient[] client_list = null;
DAOBase[] ar_main = null;
DAOBase[] ar = null;
DAOBase[] ar_ani = null;
ar_main = customer.readAll(null,"");
if(ar_main.length!=0)
{
client_list = new TEOclient[ar_main.length];
System.arraycopy(ar_main,0,client_list,0,ar_main.length);
}
if(mode.equals("3"))
{
where = "client_id="+Integer.parseInt(client);
ar = customer.readAll(null,where);
customer1 = (TEOclient) ar[0];
name = customer1.client_name;
email = customer1.client_emailid;
company = customer1.company_name;
country = customer1.country;
city = customer1.client_city;
ar = ani.readAll(null,where);
if(ar.length!=0)
87
{
client_ani = new TEOclient_ani_details[ar.length];
System.arraycopy(ar,0,client_ani,0,ar.length);
client_anis = new String[client_ani.length];
for(i=0;i<client_ani.length;i++)
client_anis[i] = client_ani[i].ani_info;
}
}
else if(mode.equals("1"))
{
name = request.getParameter("user");
email = request.getParameter("email");
country = request.getParameter("country");
city = request.getParameter("city");
company = request.getParameter("company");
//client_anis = new String[request.getParameterValues("anis").length];
String client_anis1[] = request.getParameterValues("anis");
for(i=0;i<client_anis1.length;i++)
{
client_anis[i] = client_anis1[i];
}
}
// Added by Rohit for Giving list of ANI other than of user on 9 Apr
TEOclient temp_cl = new TEOclient();
TEOclient[] tmp_cl_list = null;
if(client.equals(""))
where="";
else
where ="client_id!="+client;
ar_ani = temp_cl.readAll(null,where);
if(ar_ani.length!=0)
{
tmp_cl_list = new TEOclient[ar_ani.length];
System.arraycopy(ar_ani,0,tmp_cl_list,0,ar_ani.length);
88
for(j=0;j<tmp_de_list.length;j++)
{
if(j==tmp_de_list.length-1 && i==tmp_cl_list.length-1)
{
where +=tmp_de_list[j].ani_info;
}
else
{
where +=tmp_de_list[j].ani_info+",";
}
}
}
}
where +=")";
}
// End of Added by Rohit for Giving list of ANI other than of user on 9 Apr
ar_ani = ani_temp.readAll(null,where);
if(ar_ani.length!=0)
{
ani_list = new TEOunique_ani_temp[ar_ani.length];
System.arraycopy(ar_ani,0,ani_list,0,ar_ani.length);
}
%>
<script language="javascript">
function validate()
{
if(document.split.name.value=="")
{
alert("Enter the name of the Client");
document.split.name.focus();
return false;
}
else if(document.split.company.value=="")
{
alert("Enter the Company name of the Client");
document.split.company.focus();
return false;
}
else if(document.split.email.value=="")
{
alert("Enter the Email ID of the Client");
document.split.email.focus();
return false;
}
else if (checkemail()==false)
{
document.split.email.focus();
document.split.email.select();
return false;
}
else if(document.split.city.value=="")
{
89
alert("Enter the City name of the Client");
document.split.city.focus();
return false;
}
else if(document.split.country.value=="")
{
alert("Enter the Country name of the Client");
document.split.country.focus();
return false;
}
else if(document.split.anis.value==null || document.split.anis.value=="")
{
alert("We have to select atleast 1 ANI for the Client");
document.split.anis.focus();
return false;
}
else
{
document.split.action="http://localhost:8080/splitter_app/servlet/editClient";
document.split.submit();
function checkemail()
{
var testresults;
var str=document.split.email.value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true;
else
{
alert("Please enter a valid email address!");
testresults=false;
}
return (testresults)
}
</script>
<script language="javascript">
function test_select()
{
/*var in = document.client_sel.client.options.selectedIndex;
var value_sel = document.client_sel.client.options[in].value;*/
if(document.client_sel.client.value=="")
{
document.client_sel.action= "edit_client.jsp?a=2&mode=0";
document.client_sel.submit();
}
else
{
document.client_sel.action= "edit_client.jsp?a=2&mode=3";
document.client_sel.submit();
90
}
}
</script>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400"
style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="top">
<table bgcolor=’#0000FF’>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="586" height="24"
bgcolor="#B1E9F4">
<tr>
91
<td width="58" height="74"></td>
<td width="250" height="74" valign="bottom" colspan="2" align="right"> <font
size="3" face="Verdana">
</font>
<p><font size="3" face="Verdana" color="#0000FF">Select one Client to
view : </font></p>
</td>
<td width="232" height="74" valign="bottom">
for(i=0;i<client_list.length;i++)
{
%>
<option value="<%=client_list[i].client_id%>" <% if(client_list[i].client_id==client_id){ %>
selected<%} else{ %>''<% } %> > <%=client_list[i].client_name%> </option>
<%
}
}
else
{
for(i=0;i<client_list.length;i++)
{
%>
<option value="<%=client_list[i].client_id%>"> <%=client_list[i].client_name%> </option>
<%
}
}
}
%>
</select>
</td>
<td width="43" height="74"> </td>
</form>
</tr>
<%
if(mode.equals("1"))
{
%>
<tr>
<td width="58" height="54"></td>
<td width="53" height="54"></td>
<td colspan='2' align='center' height="54"><font color='#FF0000' face='Verdana'>
<b>
The Client Name we entered already exists<br> Please try again with new Client
Name</b></font></td>
92
<td width="43" height="54"> </td>
<%
}
else if(mode.equals("2"))
{
%>
<tr>
<td width="58" height="54"></td>
<td width="53" height="54"></td>
<td colspan='2' align='center' height="54"><font color='#FF0000' face='Verdana'>
<b>
The Edit Client process was done Successfully<br> To Edit other Client Select Client
Name from Top</b></font></td>
<td width="43" height="54"> </td>
<%
}
%>
<tr>
<form name="split" method="post">
<input type="hidden" name="client" value="<%=client%>">
<td width="58" height="49"></td>
<td width="53" height="49" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="49" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Name
of Client : </font> </td>
<td width="232" height="49" valign="bottom"><input type="text" name="name" size="20"
tabindex="1" value="<%=name%>"> </td>
<td width="43" height="49"> </td>
</tr>
<tr>
<td width="58" height="33"></td>
<td width="53" height="33" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="33" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Company
of Client : </font> </td>
<td width="232" height="33" valign="bottom"><input type="text" name="company"
size="20" tabindex="2" value="<%=company%>"> </td>
<td width="43" height="33"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> </td>
<td width="197" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Email
ID of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="email" size="20"
tabindex="3" value="<%=email%>"> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="31"></td>
93
<td width="53" height="31" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="31" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">City
of Client : </font> </td>
<td width="232" height="31" valign="bottom"><input type="text" name="city" size="20"
tabindex="4" value="<%=city%>"> </td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> <font size="3" face="Verdana">
</font> </td>
<td width="197" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Country
of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="country"
size="20" tabindex="5" value="<%=country%>"> </td>
<td width="43" height="30"> </td>
</tr>
<%
if(mode.equals("3") || mode.equals("1"))
{
%>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> </td>
<td width="197" height="30" valign="middle" align="right"><font size="3" face="Verdana"
color="#0000FF">List
of ANIs : </font> </td>
<td width="232" height="30" valign="bottom"><select name='anis' multiple size='4'
tabindex="6">
<%
if(ani_list!=null)
{
for(i=0;i<ani_list.length;i++)
{
%>
<option value="<%=ani_list[i].ani_name%>" <% if(client_anis!=null)
{ for(j=0;j<client_anis.length;j++){ if(client_anis[j].equals(ani_list[i].ani_name)){%>selected<%
break;}else
continue;}}%>>
<%=ani_list[i].ani_name%> </option>
<%
}
}
%>
</select>
<br><font size='1' face='Verdana' color='#000000'> Use CTRL key to select Multiple
ANI</font>
</td>
<td width="43" height="30"> </td>
</tr>
<%
}
94
%>
<tr>
<td width="58" height="55"></td>
<td width="251" height="55" colspan="2">
<p align="center">
</p>
</td>
<td width="232" height="55">
<input type="button" name="submit_button" value=" Update " tabindex="7"
onclick="validate()"> <input type="reset" value=" Reset " name="B2"
tabindex="8">
</td>
<td width="43" height="55"> </td>
</form>
</tr>
</table>
</center>
</td></tr>
</table>
</td></tr>
</table>
</div>
<%
}//try
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
</html>
view_client
<%
try
{
request.getSession(true);
TEOclient customer = new TEOclient();
TEOclient customer1 = new TEOclient();
TEOclient_ani_details ani = new TEOclient_ani_details();
TEOclient_ani_details[] client_ani = null;
TEOclient[] client_list = null;
DAOBase[] ar_main = null;
DAOBase[] ar = null;
DAOBase[] ar_ani = null;
ar_main = customer.readAll(null,"");
if(ar_main.length!=0)
95
{
client_list = new TEOclient[ar_main.length];
System.arraycopy(ar_main,0,client_list,0,ar_main.length);
}
String mode= request.getParameter("mode");
int i=0;
String name="";
String[] client_anis=null;
String email="";
String company="";
String city="";
String country="";
String where="";
String client="";
if(mode.equals("0"))
{
client="";
}
if(mode.equals("1"))
{
client = request.getParameter("client");
if(mode.equals("1"))
{
where = "client_id="+Integer.parseInt(client);
ar = customer.readAll(null,where);
customer1 = (TEOclient) ar[0];
name = customer1.client_name;
email = customer1.client_emailid;
company = customer1.company_name;
country = customer1.country;
city = customer1.client_city;
ar = ani.readAll(null,where);
if(ar.length!=0)
{
client_ani = new TEOclient_ani_details[ar.length];
System.arraycopy(ar,0,client_ani,0,ar.length);
client_anis = new String[client_ani.length];
for(i=0;i<client_ani.length;i++)
client_anis[i] = client_ani[i].ani_info;
}
}
}
%>
<script language="javascript">
function test_select()
{
if(document.client_sel.client.value=="")
{
document.client_sel.action= "view_client.jsp?a=3&mode=0";
document.client_sel.submit();
}
else
{
96
document.client_sel.action= "view_client.jsp?a=3&mode=1";
document.client_sel.submit();
}
}
</script>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400"
style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="top">
<table bgcolor=’#0000FF’>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="586" height="20"
bgcolor="#B1E9F4">
<tr>
97
</tr>
<center>
<tr>
<form name="client_sel" method='post'>
<td width="58" height="74"></td>
<td width="250" height="74" valign="bottom" colspan="2" align="right"> <font
size="3" face="Verdana">
</font>
<p><font size="3" face="Verdana" color="#0000FF">Select one Client to
view : </font></p>
</td>
<td width="232" height="74" valign="bottom">
for(i=0;i<client_list.length;i++)
{
%>
<option value="<%=client_list[i].client_id%>" <% if(client_list[i].client_id==client_id){ %>
selected<%} else{ %>''<% } %> > <%=client_list[i].client_name%> </option>
<%
}
}
else
{
for(i=0;i<client_list.length;i++)
{
%>
<option value="<%=client_list[i].client_id%>"> <%=client_list[i].client_name%> </option>
<%
}
}
}
%>
</select>
</td>
<td width="43" height="74"> </td>
</form>
</tr>
<tr>
<td width="58" height="57"></td>
<td width="52" height="49" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="198" height="57" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Name
98
of Client : </font> </td>
<td width="232" height="57" valign="bottom"><input type="text" name="name" size="20"
tabindex="1" value="<%=name%>" readonly="true"> </td>
<td width="43" height="57"> </td>
</tr>
<tr>
<td width="58" height="33"></td>
<td width="52" height="33" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="198" height="33" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Company
of Client : </font> </td>
<td width="232" height="33" valign="bottom"><input type="text" name="company"
size="20" tabindex="2" value="<%=company%>" readonly="true"> </td>
<td width="43" height="33"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="52" height="30" valign="bottom"> </td>
<td width="198" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">email
ID of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="email" size="20"
tabindex="3" value="<%=email%>" readonly="true"> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="31"></td>
<td width="52" height="31" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="198" height="31" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">City
of Client : </font> </td>
<td width="232" height="31" valign="bottom"><input type="text" name="city" size="20"
tabindex="4" value="<%=city%>" readonly="true"> </td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="52" height="30" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="198" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Country
of Client : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="country"
size="20" tabindex="5" value="<%=country%>" readonly="true"> </td>
<td width="43" height="30"> </td>
</tr>
<%
if(mode.equals("1"))
{
%>
<tr>
99
<td width="58" height="30"></td>
<td width="52" height="30" valign="bottom"> <font size="3" face="Verdana">
</font> </td>
<td width="198" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">List
of ANIs : </font> </td>
<td width="232" height="30" valign="bottom"><select name='anis' multiple size='4'
tabindex="6">
<%
if(client_anis!=null)
{
for(i=0;i<client_anis.length;i++)
{
%>
<option> <%=client_anis[i]%> </option>
<%
}
}
%>
</select></td>
<td width="43" height="30"> </td>
</tr>
<%
}
%>
<tr>
<td width="58" height="41"></td>
<td width="251" height="41" colspan="2">
<p align="center">
</p>
</td>
<td width="232" height="41">
</td>
<td width="43" height="41"> </td>
</tr>
</table>
</center>
</td></tr>
</table>
</td></tr>
</table>
</div>
<%
}//try
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
100
</html>
ani_page
<%
try
{
DAOBase[] ar = null;
TEOunique_ani_temp[] ani_list = null;
TEOunique_ani_temp anis = new TEOunique_ani_temp();
ar = anis.readAll(null,"");
%>
<html>
<head>
<title>DUF Result Page</title>
</head>
<body>
<center>
<br><br>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400" style="border-
collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="middle">
<table bgcolor=’#0000FF’>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="586" height="400"
bgcolor="#B1E9F4">
<tr><td height='10'> </td></tr>
<tr>
<td valign='middle' align='center'>
<b>These are the result ANI from the File :</b>
<tr><td height='10'> </td></tr>
</td></tr>
<tr>
<td align='center'>
<select name='anies' size='20' multiple>
<option> The List of ANIS </option>
<%
if(ar.length!=0)
{
ani_list = new TEOunique_ani_temp[ar.length];
System.arraycopy(ar,0,ani_list,0,ar.length);
for(int i=0;i<ani_list.length;i++)
{
%>
<option value='<%= ani_list[i].ani_id%>'><%= ani_list[i].ani_name%></option>
<%
101
}
%>
</select><br>
<a href='http://localhost:8080/splitter_app/jsp/index.html'>Go Back to Index Page</a>
<%
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</td></tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
</body>
</html>
process_file
<%
try
{
request.getSession(true);
String mode= request.getParameter("mode");
String client= request.getParameter("client");
int i=0;
String filename = request.getParameter("filename");
String tempname = filename;
String client_anis=null;
String name="";
String city="";
String company="";
String country="";
String email="";
TEOclient_ani_details ani = new TEOclient_ani_details();
102
TEOclient_ani_details[] client_ani_list = null;
DAOBase[] ar = null;
int client_id = Integer.parseInt(client);
filename="c:/jakarta/webapps/splitter_app/readable/"+filename+".txt";
FileWriter buf = new FileWriter(filename);
String where ="client_id="+client_id;
ar = ani.readAll(null,where);
if(ar.length!=0)
{
client_ani_list = new TEOclient_ani_details[ar.length];
System.arraycopy(ar,0,client_ani_list,0,ar.length);
}
TEOunique_ani_temp u_temp = new TEOunique_ani_temp();
TEOani_row_table row_t = new TEOani_row_table();
TEOani_row_table[] row_list = null;
for(i=0;i<client_ani_list.length;i++)
{
where = "ani_name='"+client_ani_list[i].ani_info+"'";
ar = u_temp.readAll(null,where);
u_temp = (TEOunique_ani_temp) ar[0];
where = "ani_id="+u_temp.ani_id;
ar = row_t.readAll(null,where);
row_list = new TEOani_row_table[ar.length];
System.arraycopy(ar,0,row_list,0,ar.length);
for(int j=0;j<row_list.length;j++)
{
buf.write(row_list[j].row_details+"\n");
}
}
System.out.println("test "+filename);
buf.close();
FileDataSource fds = new FileDataSource(filename);
File f=fds.getFile();
FileInputStream fs = new FileInputStream(f);
InputStreamReader file = new InputStreamReader(fs);
BufferedReader b = new BufferedReader(file);
String line="";
String output="";
// Mail Sending
String host="210.7.88.226";
Properties props =System.getProperties();
props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");
103
Session mailSession= Session.getDefaultInstance(props,null);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress("projects@planetwire.net"));
InternetAddress[] address = {new InternetAddress(customer.client_emailid)};
msg.setRecipients(RecipientType.TO,address);
msg.setSubject(Subject);
// Attaching File
bodyPart.setDataHandler(new DataHandler(fds));
bodyPart.setFileName(tempname+".txt");
multiPart.addBodyPart(bodyPart);
MimeBodyPart main = new MimeBodyPart();
main.setText(Message);
multiPart.addBodyPart(main);
msg.setContent(multiPart);
Transport.send(msg);
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400"
style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="top">
<table bgcolor=’#0000FF’ height="396">
104
<tr>
<td height="392">
<table border="0" cellpadding="0" cellspacing="0" width="586" height="410"
bgcolor="#B1E9F4">
<tr>
<td width="58" height="58"></td>
</center>
<td width="475" height="58" style="border-bottom-style: solid; border-bottom-color:
#1AD8E1" colspan="3" >
<p align="center"><b><font color="#000099" size="4" face="Verdana">SPLIT
FILE PAGE</font></b></p>
</td>
<td width="43" height="58"> </td>
</tr>
<center>
<tr>
</tr>
<tr>
<td width="58" height="31"> </td>
<td width="53" height="31" valign="bottom"> </td>
<td width="197" height="31" valign="bottom" align="right">
<textarea name='area' rows='20' cols='50'><%=output%> </textarea></td>
<td width="232" height="31" valign="bottom"> </td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="31"></td>
<td width="482" height="31" valign="bottom" colspan="3"> <font size="3"
face="Verdana">
</font>
<p align="center"><font size="3" face="Verdana" color="#0000FF"><b>The
File split Process is completed</b>
<br>The mail is sent with Split DUF attachment.<br>
To Go on Split page <a href="split_file.jsp?a=4&mode=0">Click Here</a> </font></p>
</td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="482" height="30" valign="bottom" colspan="3"> <font size="3"
face="Verdana">
</font> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="1"> </td>
<td width="483" height="1" colspan="3">
</td>
<td width="43" height="1"> </td>
</tr>
<tr>
105
<td width="58" height="104"></td>
<td width="251" height="104" colspan="2">
<p align="center">
</p>
</td>
<td width="232" height="104">
</td>
<td width="43" height="104"> </td>
</tr>
</table>
</center>
</td></tr>
</table>
</td></tr>
</table>
<%
}// try
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
</html>
split_file
<%
try
{
request.getSession(true);
String mode= request.getParameter("mode");
int i=0;
String client_anis=null;
String name="";
String city="";
String company="";
String country="";
String email="";
TEOclient client = new TEOclient();
TEOclient[] client_list = null;
DAOBase[] ar = null;
ar = client.readAll(null,"");
if(ar.length!=0)
{
client_list = new TEOclient[ar.length];
106
System.arraycopy(ar,0,client_list,0,ar.length);
}
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table border="0" cellspacing="0" width="780" id="AutoNumber1" height="400"
style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td width="21%" height="400" bgcolor="#B1E9F4" rowspan="3" valign="top">
<br><br>
<jsp:include page="leftbar.jsp" flush="true"/>
</td>
<td width="79%" height="338" align="center" valign="top">
<table bgcolor=’#0000FF’ height="396">
<tr>
<td height="392">
<table border="0" cellpadding="0" cellspacing="0" width="586" height="410"
bgcolor="#B1E9F4">
<tr>
<td width="58" height="58"></td>
</center>
<td width="475" height="58" style="border-bottom-style: solid; border-bottom-color:
#1AD8E1" colspan="3" >
<p align="center"><b><font color="#000099" size="4" face="Verdana">SPLIT
FILE PAGE</font></b></p>
</td>
<td width="43" height="58"> </td>
</tr>
<center>
<tr>
<form name='split' method='post' action="process_file.jsp?a=0">
</tr>
<tr>
<td width="58" height="31"> </td>
<td width="53" height="31" valign="bottom"> </td>
<td width="197" height="31" valign="bottom" align="right"> </td>
<td width="232" height="31" valign="bottom"> </td>
<td width="43" height="31"> </td>
107
</tr>
<tr>
<td width="58" height="31"></td>
<td width="53" height="31" valign="bottom"> <font size="3"
face="Verdana">
</font> </td>
<td width="197" height="31" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Select
Client : </font> </td>
<td width="232" height="31" valign="bottom"><select name='client' size='1'>
<option value=''> Select a Client </option>
<%
for(i=0;i<client_list.length;i++)
{
%>
<option value="<%=client_list[i].client_id%>"> <%=client_list[i].client_name%>
</option>
<%
}
%>
</select></td>
<td width="43" height="31"> </td>
</tr>
<tr>
<td width="58" height="30"></td>
<td width="53" height="30" valign="bottom"> <font size="3" face="Verdana">
</font> </td>
<td width="197" height="30" valign="bottom" align="right"><font size="3" face="Verdana"
color="#0000FF">Write
File Name : </font> </td>
<td width="232" height="30" valign="bottom"><input type="text" name="filename"
size="20" tabindex="5"> </td>
<td width="43" height="30"> </td>
</tr>
<tr>
<td width="58" height="1"> </td>
<td width="251" height="1" colspan="2">
</td>
<td width="232" height="1">
<input type='submit' name='submit' value=' Split ' tabindex="7">
</td>
<td width="43" height="1"> </td>
</tr>
<tr>
<td width="58" height="104"></td>
<td width="251" height="104" colspan="2">
<p align="center">
</p>
</td>
<td width="232" height="104">
</td>
<td width="43" height="104"> </td>
</form>
108
</tr>
</table>
</center>
</td></tr>
</table>
</td></tr>
</table>
<%
}// try
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
</html>
Leftbar
<%
try
{
String url="";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>
c=request.getParameter("a");
if(c.equals("1"))
{
%>
</font>
<b>
<font face="Verdana" size="3"
color="#0000FF">Create Client</font></b><font face="Verdana" size="2"><br>
<br>
109
<br>
<br>
<%
url = response.encodeRedirectURL("edit_client.jsp?a=2&mode=0");
%>
<a href="<%=url%>">
Edit Client</a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("view_client.jsp?a=3&mode=0");
%>
<a href="<%=url%>">
View Clients</a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("split_file.jsp?a=4&mode=0");
%>
<a href="<%=url%>">
Split File</a><br>
<%
}
else if(c.equals("2"))
{
%>
<b>
<font face="Verdana" size="3" color="#0000FF">Edit Client</font></b><br>
<br>
<br>
<br>
<%
url = response.encodeRedirectURL("add_client.jsp?a=1&mode=0");
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
Create Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("view_client.jsp?a=3&mode=0");
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
View Clients</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("split_file.jsp?a=4&mode=0");
%>
110
<a href="<%=url%>">
Split File</a><br>
<%
}
else if(c.equals("3"))
{
%>
<b>
<font face="Verdana" size="3"
color="#0000FF">View Clients</font></b><br>
<br>
<br>
<br>
<%
url = response.encodeRedirectURL("add_client.jsp?a=1&mode=0");
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
Create Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("edit_client.jsp?a=2&mode=0");
%>
<a href="<%=url%>"><font face="Verdana" size="2">
Edit Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("split_file.jsp?a=4&mode=0");
%>
<a href="<%=url%>">
Split File</a><br>
<%
}
else if(c.equals("4"))
{
%>
<b>
<font face="Verdana" size="3" color="#0000FF">Split File</font></b><br>
<br>
<br>
<br>
<%
url = response.encodeRedirectURL("add_client.jsp?a=1&mode=0");
111
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
Create Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("edit_client.jsp?a=2&mode=0");
%>
<a href="<%=url%>"><font face="Verdana" size="2">
Edit Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("view_client.jsp?a=3&mode=0");
%>
<a href="<%=url%>">
<%
}
else
{
%>
<font face="Verdana" color="#0000FF" size="6"> D U F App</font><br><br><br>
<%
url = response.encodeRedirectURL("add_client.jsp?a=1&mode=0");
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
Create Client
</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("edit_client.jsp?a=2&mode=0");
%>
<a href="<%=url%>">
<font face="Verdana" size="2">
Edit Client</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("view_client.jsp?a=3&mode=0");
%>
<a href="<%=url%>">
<font size="2" face="Verdana">
View Clients</font></a><br>
<br>
<br>
<%
url = response.encodeRedirectURL("split_file.jsp?a=4&mode=0");
%>
112
<a href="<%=url%>">
Split File</a><br>
<%
}
%>
</td>
<td width="1%" height="100%"> </td>
</tr>
</table>
<%
}
catch(Exception e)
{
System.out.println(e.toString());
}
%>
</body>
</html>
3) HTML FILE
Index
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>DUF Application</title>
</head>
<body>
<p align="center"> </p>
<div align="center">
<center>
<table bgcolor=’#0000FF’>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="586" height="187"
bgcolor="#B1E9F4">
<tr>
<form name='split' method='post' ENCTYPE="multipart/form-data"
action="http://localhost:8080/splitter_app/servlet/split">
<td width="58" height="23"></td>
<td width="479" height="23"></td>
113
<td width="43" height="23"> </td>
</tr>
<tr>
<td width="58" height="33"></td>
</center>
<td width="475" height="33" style="border-bottom-style: solid; border-bottom-color:
#1AD8E1" >
<p align="center"><b>
<font color="#000099" size="4" face="Verdana">FILE SPLITTER</font></b></p>
</td>
<td width="43" height="33"> </td>
</tr>
<center>
<tr>
<td width="58" height="76"></td>
<td width="475" height="76" valign="bottom"> <font size="3" face="Verdana"><font
color="#0000FF">Select the File For splitting :</font>
</font><input type='file' name='upload'> </td>
<td width="43" height="76"> </td>
</tr>
<tr>
<td width="58" height="40"></td>
<td width="475" height="40">
<p align="center">
<input type='submit' name='submit' value=' Submit '></p>
</td>
<td width="43" height="40"> </td>
</form>
</tr>
<tr>
<td width="58" height="40"></td>
<td width="475" height="40">
<p align="center">
<a href="http://localhost:8080/splitter_app/jsp/ani_page.jsp?a=0"
target="_blank"><b>Manage Clients</b></a></p>
</td>
<td width="43" height="40"> </td>
</table>
</td></tr>
</table>
</div>
</body>
</html>
4)XML FILE
Web
114
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>initialization</servlet-name>
<servlet-class>planetwire.smsapp.servlets.InitServlet</servlet-class>
<init-param>
<param-name>splitter_app.dbURL</param-name>
<param-value>jdbc:mysql://localhost:3306/splitter</param-value>
<!--param-
value>jdbc:weblogic:mssqlserver4:sms_app_db@pwserver:1433</param-value!-->
</init-param>
<init-param>
<param-name>splitter_app.dbUser</param-name>
<param-value>root</param-value>
</init-param>
<init-param>
<param-name>splitter_app.dbPassword</param-name>
<param-value>ankita</param-value>
</init-param>
<init-param>
<param-name>splitter_app.driverClass</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
<!--param-value>weblogic.jdbc.mssqlserver4.Driver</param-
value!-->
</init-param>
</servlet>
<servlet>
<servlet-name>addClient</servlet-name>
<servlet-class>planetwire.splitter.servlets.AddUserServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>editClient</servlet-name>
<servlet-class>planetwire.splitter.servlets.EditUserServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>split</servlet-name>
<servlet-class>planetwire.splitter.servlets.SplitterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>logon</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
115
116