2

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 66

DELETE

Directory

Select the side


where u want to
delete Directory

YES
select the
Client Side?
Directory Name
NO

select the
Directory Name
YES
If the
selected
name is
YES
If the NO
selected Directory will be
deleted
name is
The File may
not be Deleted
NO

The File may


not be Deleted
Directory will be
deleted

Return
RNM

RENAME File

Chose the side


where u want
to rename

YES Select the File to


Client Side ? rename
NO

Select the File to


rename NO

Is It the file ?

NO
YES

Is It the file ?
Enter the New Cannot be
name for File renamed
YES

Cannot be
Enter the New renamed The selected file
name for File was renamed

The selected file


was renamed Retur
n
DEF

DELETE File

Chose the
side where u
want to delete
file

Client Side ?

NO
NO
If it is File If it is File ?
?

YES
YES Deletion Failed
Deletion Failed

Selecte
Selecte d file
d file will be
will be

Return
DWN
UP

Select the file Select the file to


to Upload in Download on
Client Side Server file list

Using FTP settings


Using FTP settings
set the speed with
set the speed with
which the file is to
which the file is to
be transferred
be transferred

Selected File will Selected File will


be Uploaded be Downloaded

Retur
n
4.5.3 E-cabinet Module

START

NO

Existing
User? SIGN UP

YES

LOGIN

NO
YES

VALID E-Cabinet Handler


?

E-cab

E-cab
E-Cabinet Handler

READ File SAVE File

NO

YES

File Selected? Selected File is saved


READ Handler in Server
READ Handler

OPEN RENAME DELTE

REQUEST TO
Server With Enter The
Filename Enter the File To
Valid Delete
rename
No
NO
If the File
Exsists YES
File DELETE
Yes Present File

Contents Of The
File Will be
Displayed
5.IMPLEMENTATION
5.1 PSEUDO CODE OF MODULES
5.1.1 Communication With WEB Server
HISTORY CLASS:

Introduction:
This module provides the basis for most of the other sub-modules
like PREVIOUS, NEXT. Basically this module is used to keep track of the URL
pages visited. Similar to Internet Explorer here also we can keep history settings
as our requirement.
Design:
Before going to actual design we need to know some information
regarding System Properties. Some of these which are used in our Project are as
Follows

System.getProperty("user.home")

This will return the directory under which the current Operating
System on which the software is being run. For example if user is currently is
working under "Windows Operating System" and “OS” was loaded in drive D,
then this function will return "D:"
Ex: D:\Windows
In Order to retrieve the offline pages efficiently they are temporarily
stored in an user defined directory. For this Module we have created an
user defined file "UCOfflineDir" to serve as a temporary storage

System.getProperty ("file.separator")
This function will return the character that is used as a file separator.
By default in “Windows Operating System” the file separator is “\”. This
represents an Hierarchical way representation for the files stored in the system.
This property is used in “History Module” to create the temporary files needed to
store the visited “Offline Pages”

The user defined functions that are required for designing HISTORY
class are described below

public URL getPreviousPage() throws Exception


This Function will return the URL of the page that is being
visited before the current page. Implicitly this means that if there is only a single
page visited so far then this function will return the URL of the current page itself.

Public URL getNextPage( ) throws Exception


This function will return the URL of the page (atleast once)
visited after the current page (i.e., this page is visited before the required page
earlier). Implicitly this means that if there is a single page that is visited so far
then this function will return the URL of the current page itself.

Public void clearHistory( )


This function will clear the list of the URL's from the AddrBar
when we press ClearHistory option in the SETTINGS module otherwise this will
display some message using JOPTIONPANE class as
JOptionPane.showInternalMessageDialog (parent,"Unable to clear
History","History Listing",JOptionPane.ERROR_MESSAGE)

private void maintainOfflineContent(String file)


This function will maintain the page that is visited in the form of an
offline page with the path resulted from the following

String separator = System.getProperty("file.separator");


String dirName = "UCOfflineDir";
String path = System.getProperty("user.home") + separator;
path = path + dirName;
String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));
String month = String.valueOf(calendar.get(Calendar.MONTH)+1);
String year = String.valueOf(calendar.get(Calendar.YEAR));
String date = day + "_" + month + "_" + year;//to display properly in tree
//since 0 is JANUARY
path = path + separator + "UC" + date;

That is the offline page will be

String file1 = new URL(file).getFile();


This will return the actual URL file
Ex: http:/www.sun.java/tutorials/index.thml

String fileName = file1.substring(file1.lastIndexOf("/")+1);


This will return just the file name of the URL
Ex: index.html
String offlineFile = path + separator + fileName;
Here offline file is the path name for the URL in the local System

Then the current file is being downloaded into the offline page
whose path is already set. Here for downloading this function will call a
Download function
which uses the URL class along with BufferedInputStream for reading and
FileOutputStream for writing.

myURL = new URL(file);

con = myURL.openConnection();

bis = new BufferedInputStream(con.getInputStream());


FileOutputStream out = new FileOutputStream(destination);

This function will also map files to respective URL by calling a function
which uses FileWriter class as shown below

FileWriter fw = new FileWriter(path + "UCMapping.uc",true);

private void checkOfflineDirAvailability(String directory)


This file will check whether the Offline directory is already
available If it doesn't exists then it creates a new directory as
dir.mkdir()

public Vector retrieveOfflinePages()


This function will return the list of the directories created according
to history settings. It means that it will return the list of day’s
public void mapFilesToRespectiveUrl(String path,Stringreal,String temp)
This function will map the OfflinPage to the respective URL.

public DefaultMutableTreeNode
addChildNodesFor(DefaultMutableTreeNode parent)
This function will add the Childs to their parent in a hierarchical
fashion, which is being called for obtaining a tree like hierarchical structure.

TREEVIEWOFFLINE CLASS:
INTRODUCTION:
This class is basically responsible for obtaining tree like structure of
the history that is being maintained. This will assume "HISTORY" as the root
directory and then adds child nodes to it hierarchically.
DESIGN:
Public
TreeViewOfflineFiles(Historyhistory, DefaultMutableTreeNode
root,DefaultTreeModel treeModel)

This function will declare a tree and made it follow a default tree model as
Tree = new JTree (treeModel);
public DefaultMutableTreeNode getOfflineFiles() throws
Exception
This function will declare the root node as
DefaultMutableTreeNode rootNode = new
DefaultMutableTreeNode("History");
Then this will retreive the offline pages and adds them as childs
to their respective parents as shown below
DefaultMutableTreeNode child = new DefaultMutableTreeNode (v.elementAt(i));
child = history.addChildNodesFor(child);
rootNode.add(child);

CODEVIEWER CLASS:
Introduction:
This class is basically designed using SWING, IO,
AWT, and NET packages in JAVA. Its purpose is to provide the user the
source code of the html file he is currently viewing.
Design:
The codeviewer is an internal frame developed using
the JInternalFrame class.a desktop pane is used as a container to all the
objects in the codeviewer frame. An editor pane is used to display the
source code of the html file and a scroll pane is used to provide the scroll
bars needed for the editor pane.
JInternalFrame codeView;
JEditorPane codePane;
JScrollPane scrollCode;
codePane = new JEditorPane();
scrollCode = new JScrollPane(codePane);
codeView = new JInternalFrame("Code Viewer",false,true,true,true);
To provide the link between the client and the html
file the URL class and URLConnection class present in the net package are
used. URL class creates an object for the URL address specified in the
address bar. URLConnection provides a stream for reading from and
writing to the URL.
URL myURL;
URLConnection con;
A buffered input stream is created for reading the
contents of the html file specified in the address bar.
bis = new BufferedInputStream(con.getInputStream( ));

URL class has a method called getFile( ) which will


return the file name that is being viewed. The source code will be retrieved
in a string format and will be displayed in the editor pane using the setText
method.
codePane.setText(str);

MAIL HANDLER CLASS:


Introduction:
This is a sub module in the HTTP handler.It primarily deals with the
option of sending messages to the user via a SMTP mail server. Mail Handler
will be activated upon clicking the MAIL button in the browser, A dialog box is
popped up on the screen which will enable the user to enter his mail address and
the receiver’s mail address. It also provides the option of carbon copying the
message by providing CC and BCC.A text area is provided for typing the
message and user can send any attachments along with the message by clicking
ATTACHMENT and selecting the required file. Finally clicking the SEND button
will send the message and CANCEL will undo it.
Design:
MAIL HANDLER is basically created with the help of importing IO, NET,
SWING, AWT, AWT.EVENT, and AWT.COLOR packages in JAVA.
The dialog box that the user sees upon clicking MAIL is an
internal frame created by using JinternalFrame class. A desktop pane called
parent is created by using Jdesktoppane class which will act as a container for all
the objects in the frame. A text area is created using JTextArea class which is
then passed as parameter to scroll pane for enabling scrollbars (vertical). The
property SetLineWrap is enabled so that horizontal scroll bar is not required.

JInternalFrame mail;
JScrollPane consolePane;
JDesktopPane parent;

txtMsg = new JTextArea();


txtMsg.setLineWrap(true);
consolePane = new JScrollPane(txtMsg);

A set of labels and their respective text fields are


created for taking the mail id’s of sender and receiver and for Cc and Bcc.
These are created using classes JLabel and JtextField. Three buttons
btnSend, btnCancel, btnAttachment are created using Jbutton class.

JLabel lblFrom, lblTo, lblSubject, lblAttachment, lblCc, lblBcc;


JTextField txtFrom, txtTo, txtSubject, txtCc, txtBcc;
The user can add an attachment (a maximum of 1) to his mail by
clicking the attachment button. Upon clicking the attachment an open-file dialog
box is popped up which will enable user to select his required file. For this
purpose a class called JFileChooser is used.
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);//only 1 attachment
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setDialogTitle("File Attachment");
chooser.setApproveButtonToolTipText("Select a file and Click me");
int select = chooser.showOpenDialog(parent);
If (select == JFileChooser.APPROVE_OPTION)
{
lblAttachment.setText("Attachment : " +
chooser.getSelectedFile().getParent()+"\\"+chooser.getSelectedFile().getName()+
"(" + chooser.getSelectedFile().length()+")byte(s)");
attachmentFile = new File(chooser.getSelectedFile().getName());
}

For sending the message from sender to recipient an SMTP mail


server such as YAHOO mail server is used. The port number for SMTP is 25 and
a mail server indefinitely listens to that port number for requests from clients. We
establish the connection between SMTP server and client by using SOCKET
class. The message/file is sent as a stream of bytes using the BufferedReader
and PrintWriter classes.

Socket sendSocket = new Socket ("smtp.yahoo.com",25);//25 for SMTP

BufferedReader in = newBufferedReader
(newInputStreamReader (sendSocket.getInputStream ()));

PrintWriter out = new PrintWriter(new


OutputStreamWriter(sendSocket.getOutputStream()),true);

Upon clicking the CANCEL the internal frame should be closed and
disabling the desktop pane visibility does this.
mail.setVisible(false);

PRINT CLASS (DR):


Design:
Java supports high-quality printing through classes in the Java.awt.print
package.
There are two basic steps required to print: settting up the print job,
and rendering graphics on the printer.

1. Setting Up the Print Job

This is virtually always done the same way: get a


PrinterJob object, pass a Printable to its setPrintable method, call printDialog to
pop up an OS-specific print dialog, and finally, assuming the user hasn't
cancelled the printing from the dialog (you check this by testing the return
value of printDialog), call print on the PrinterJob. The role of the Printable is to
define a print method showing how the actual drawing to the printer will be
done.

PrinterJob printJob = PrinterJob.getPrinterJob();

protected void printDialog()


{
if (pJob.printDialog())
{
pJob.setPrintable(this,pFormat);
try
{
pJob.print();
}
catch (PrinterException printerException)
{
pageStartY = 0;
pageEndY = 0;
currentPage = -1;
System.out.println("Error Printing Document");
}
}
}

1. Here's a representative sample of what you see when you call printDialog:
2.Rendering Graphics on the Printer

The Printable that is passed to setPrintable must have a print


method that describes how to send drawing to the printer. In general, the
first step is to decide what to do for different pages of your print job, since
Java repeatedly calls print with higher and higher page indexes until print
returns NO_SUCH_PAGE. In the specific case of printing Swing components,

however, you only have a single page. So you return PAGE_EXISTS for
index 0, NO_SUCH_PAGE otherwise.
The second step is to start drawing. In general, you can do any sort of
drawing you want. In the specific case of printing Swing components,
however, your drawing should just be a high-resolution version of what the
component looks like on the screen. So you cast the Graphics object to
Graphics2D, scale the resolution to the printer, and call the component's
paint method with this scaled Graphics2D.

public int print (Graphics graphics, PageFormat pageFormat, int pageIndex)


{

Graphics2D graphics2D;
graphics2D = (Graphics2D) graphics;
graphics2D.translate(graphics2D.getClipBounds().getX(),
graphics2D.getClipBounds().getY());
if (printView(graphics2D,allocation,rootView))
{
return Printable.PAGE_EXISTS;
}
else
{
pageStartY = 0;
pageEndY = 0;
currentPage = -1;
return Printable.NO_SUCH_PAGE;
}
}

HTTPHandler Class :
This class is the main class that is responsible for all the under
going operation in this “Browser”. All the classes that are mentioned above are
imported in this class. Also all the preceding classes communicate with this class.
This class is also responsible for handling of many events’ that are occurred with
the HTTPHandler.Any command the user will give must be first recognized by
this class. Then using the sub modules like “HISTORY”,”PRINT”,”MAIL
HANDLER” it will execute the requested command. For example if the user want
to see the “Previous Page” then this module will retrieve the required page from
“HISTORY” module

5.1.2 Communication With FTP Server


Introduction:

The ability to transfer files from one machine to another is often


accomplished using an FTP client. In order to achieve the desired
functionality we have extensively used the predefined classes provided by
JAVA - programming language. JAVA provided soo many builtin functions that
provided the basic functionalities of the FTP client

Connection-Establishment:

In order to communicate with FTP server we must first establish a


connection with FTP server. Before doing connection we need to create an
FTP instance with FTP hostname, User name, Password. To create an
instance of FTP we use the “predefined constructor” provided in JAVA
package called Ftp().We create an FTP instance as follows

Ftp ftp = new Ftp()


Now we can make an connection instance using the “predefined constructor”
provided in JAVA called “FtpConnect()”.

Ex: FtpConnect myConnect = new FtpConnect();

Once we had created an Connection instance we need to specify the


parameters like “Hostname” ,”Port no” ,”User name” ,”Path name”, ”Pass
word”. This can be made using the methods provided for “FtpConnect”
instance.

For example:

myConnect.setHostName (txtHostName.getText())

myConnect.setPortNum(Integer.parseInt(txtPortNum.getText()))

myConnect.setUserName(txtUserID.getText())

myConnect.setPathName(txtPathName.getText())

myConnect.setPassWord(new String(txtPassword.getPassword()))

USER - user name

The user identification is that does require the server for access to its file
system. This command will normally be the first command transmitted by the
user after the control connections are made (some servers may require this).
Additional identification information in the form of a password and/or an
account command may also be required by some servers. Servers may allow
a new USER command to be entered at any point in order to change the
access control and/or accounting information. This has the effect of flushing
any user, password, and account information already supplied and beginning
the login sequence again. All transfer parameters are unchanged and any file
transfer in progress is completed under the old access control parameters

PASS - password.

This command must be immediately preceded by the user name command,


and, for some sites, completes the user's identification for access control.
Since password information is quite sensitive, it is desirable in general to
"mask" it or suppress typeout. It appears that the server has no foolproof way
to achieve this. It is therefore the responsibility of the user-FTP process to
hide the sensitive password information.

username - Server account username.


password - Server account password

Now we can easily connect to the FTP server using the method provided for
“Ftp” instance called “connect” ,as follows

ftp.connect(myConnect)

this method will return Boolean value “true” if the connection was
successfully made otherwise it returns “false”

Disconnection:

Once the desired operations are completed we can


simply close the connections using the Ftp method
“disconnect()” as follows

ftp.disconnect();
this function will disconnect the server and closes the
control connections

Performing Directory Listing:

Once we have created the Connection with FTP server we can


make directory listing using the method called “pwd()” provided in “Ftp”
class.This method will return the server current working directory. After that we
can get the files present in the current directory using the method
“listCoFiles()”.In order to use this method we need first to create an instance of
“CoFile” object. This CoFile class is used to manipulate files from various
sources. The “pwd()” method provided by the Ftp class gives the current working
directory. By using this we can get back the files associated with this directory as
follows

CoFile hostDir = new FtpFile(myFtp.pwd(),myFtp);

PWD - print working directory

This command causes the name of the current working directory to be


returned in the reply.

Returns:
Current working directory.

FtpFile(java.lang.String path,Ftp client)

Creates a new FtpFile instance by converting the given pathname


string into an abstract pathname.
CoFile hostFiles[ ] = hostDir.listCoFiles();

Returns an array of abstract pathnames denoting the files in the directory


denoted by this abstract pathname. If this abstract pathname does not denote
a directory, then this method returns null. Otherwise an array of File objects is
returned, one for each file or directory in the directory. Pathnames denoting
the directory itself and the directory's parent directory are not included in the
result. Each resulting abstract pathname is constructed from this abstract
pathname. There is no guarantee that the name strings in the resulting array
will appear in any specific order; they are not, in particular, guaranteed to
appear in alphabetical order.

Once we have connected to the FTP server we can get the list of files
present in the current working directory on the right side table of the FTP
internal frame. Now we can make the operations on either Local / Server side.
The side on which we wish to perform the operation is specified by selecting
the file tables present on each side

Making Directory:

We can make it possible to create a new directory both at “Ftp server”


side and at “Ftp Client” side. In order to create a new directory at Client side we
can simply invoke the method “mkdir()” provided in class “File”.

File dir = new File(cmbLocalDir.getDir().getAbsolutePath() + "\\" + dirName);

To create directory at server side we can similarly make use of


“mkdir(java.lang.String directory)” method provided for “Ftp” class.

Ex: myFtp.mkdir(dirName)
This command causes the directory specified in the pathname to be
created as a directory (if the pathname is absolute) or as a subdirectory of
the current working directory (if the pathname is relative).

This function will return “true” if the operation was success otherwise it
returns “false”. The case in which the “mkdir()” will return false is

1) When the specified directory is already present in the


current drive
2) Whenever some access restriction are specified like
“Memory out of range”

In either case the directory creation was failed and simple message box
will be displayed indicating the reason for the failure of creation.

Deleting Directory:

Similar to above case we can also make it possible to delete directory both
at server side and at client side. To delete file at the client side we first create an
instance of “File” with the specified file name. Then we call the “delete()” method
with the corresponding file object

Ex: File dir = new File(dirName);

If( dir.isDirectory() && dir.delete())

Here if the requested Directory was deleted successfully then a Boolean


“true “ value will be returned otherwise “false” will be returned. The case in
which the operation returns “false” is when the selected file is not a
directory.Suppose if the user selects a single file and makes a “Delete Directory”

command the “delete” function will return a Boolean “false” When the specified
directory was deleted the entire files present in the directory was deleted.

To delete at the server side we use the method

ftp.rmdir(java.lang.String directory)

RMD - remove directory.

This command causes the directory specified in the pathname to be


removed as a directory (if the pathname is absolute) or as a subdirectory
of the current working directory (if the pathname is relative).

Parameters:
directory - Name of directory to be removed.
Returns:
True on success.

if the requested directory was deleted successfully a Boolean “true” will


be return otherwise “false” will be reutrn

Deleting File:

It can also possible to delete a single file. This can be made both at the
Client side and at the Server side. For Client side the normal method that was
used to delete a directory can also be used to delete a single file.
Ex: myFile.delete() where “myFile” is object associated with the
file to be deleted

To delete file at the Server side we use the method provided


for “Ftp” class known as “rm()”

Ex: myFtp.rm(java.lang.String filename) Deletes the server file

Delete server file.

DELE - delete.

This command causes the file specified in the pathname to be deleted at


the server site. If an extra level of protection is desired (such as the query,
"Do you really wish to delete?"), it should be provided by the user-FTP
process.

Parameters:
filename - Name of file to be deleted.
Returns:
True on success.

If the requested file was removed “true” will be return otherwise “false” will be
return

Renaming a File:

To rename a file at Client side we need to get first the object


associated with the target file to be renamed. Once we obtain the object we can
rename the old file with the new one using the method called “rename()”.
Ex: oldFileName.renameTo (newFileName)

Here oldFileName is the object associated with the file to be


renamed and newFileName is the rename of the file.

To rename at the Server side we can simply use the method called “mv”
provided in the Ftp calss.

Ex: myFtp.mv(oldfilename,newfilename)

Parameters:
oldfilename - Old name of file.
newfilename - New name of file.

This method will return the Boolean value “true” if the respective
file is successfully renamed otherwise it returns “false”.

Uploading the File:

Uploading is the process of loading the desired client file into the server
address space. To write the data into the associated FTP server we need to get
an object which refers the Outputstream. To open the Outputstream object we
need to instantiate an “FtpOutputStream” object as follows

FtpOutputStream out = new FtpOutputStream (FtpFile file)

The above statement opens the file for writing in the Server side. Once the file
object stream is obtained we need opened the file to be written in Inputstream
mode for reading the contents of the file.

in = new FileInputStream(file.getAbsolutePath());
out = new FtpOutputStream(newFtpFile(dir,file.getName(),myFtp))

byte b[ ] = new byte[uSpeed];

Herer uSpeed specifies the speed with which the data is to be transferred

while((bytes = in.read(b)) > 0){

out.write(b,0,bytes)}

Downloading the File:

Downloading is the process of loading the file from the FTP server. In
order to perform the downloading operation we used the InputStream class
associated for the Ftp server, called as FtpInputStream.

Ex:FtpInputStream(FtpFile file)

This method will opens the retrieve inputstream for the FtpFile .
Once the InputStream file was opened we need to write the data into the desired
output file. To write the data we need to open the open the file in using
Outputstream. To write the data we need first to store it in temporary buffer, later
the contents of the buffer are written into the desired file.

FileOutputStream out=null;

in = new FtpInputStream(ftpFile);

FtpFile ftpFile;

out = new FileOutputStream(f.getAbsolutePath(),append);


dir = myFtp.pwd();

ftpFile = new FtpFile(dir + file.getName(),myFtp);

byte b[ ] = new byte[dSpeed]

while((bytes = in.read(b)) > 0){

out.write (b,0,bytes)}

5.1.3 E-Cabinet For File Storage Over a Network


Function of the Server
The Server Code is written as an Application program. This is because the
server will be running continuously at the sever machine on a network. As
the server has to respond to various requests from clients, a mechanism
has to be conceived wherein each client can be communicated with
independently. This can be achieved with maximum ease by allotting a
separate port for each client who makes a request. In any computer ports 0
to 512 are allocated for exclusive use of the computer’s Operating System
and various other protocols. Thus a number higher than 512 has to be
chosen for our sever port. Thus the default port at which the server listens
for any incoming request from a client is port number 1055 which has been
specially allocated for the purpose. As the server has to respond to various
requests from clients, a mechanism has to be conceived wherein each client
can be communicated with independently. This can be achieved with
maximum ease by allotting a separate port for each client who makes a
request. In any computer ports 0 to 512 are allocated for exclusive use of
the computer’s Operating System and various other protocols. Thus a
number higher than 512 has to be chosen for our sever port. Thus the
default port at which the server listens for any incoming request from a client
is port rver has to spawn a thread for each request generated by a client it is
essential for the server to implements the Runnable interface which is
necessary for the ‘run’ method which executes for each thread. Using the
Runnable interface enables our server to be a truly multithreaded model.

The main problem is how to communicate between the client and the
server. This has been achieved in the software using a unique data
structure known as the ‘Vector’. The Vector is analogous to the array except
that it can have elements of various data types. This is of course exactly
what we need, because our information between the server and client
consist of many types of fields.

A flag which will tell the server what action has been requested by the
client. One or more fields specific to the operation desired to be performed
by the user.As the server has to be always in a state of alert as to listen to
information sent from the client, an inputstream as well as an output stream
is associated with the Server socket. The server sets up a connection with
the socket of the client machine at the local port of the client machine. Thus,
a two way information channel is set up between the server and the
instance of the client thread.
As mentioned above, the client sends requests regarding actions to be
performed using flags. These flags are essentially strings. The flags used in
this software are mentioned below

Adduser – This flag is sent by a client whenever there is a new user who wants
to sign up to the service and thereby creates his own login on the server. This is
sent as the 3rd element of a Vector of size 3. In addition the Vector contains the
user’s chosen login name as well as his password.

Defile – This flag is sent by a client whenever the user wants to delete a file from
the login. This is sent as the 3rd element of a vector of size 3. The Vector also
contains the user’s loginname as well as the filename that has to be deleted.

Getlist – This flag is used to inform the server to send all the filenames of the
files present in a use’s login. In case the login is empty a message must be
displayed which says that the login is currently empty. The flag is the 3rd element
of the Vector which also contains the loginname as well as the password of the
user.

Renamefile – This flag is sent by the client instance whenever the user wants to
rename a file in his login to a new name. Here the flag is the 4th field in the vector
and also contains the login, the name of the file, and the new name of the file.

Savefile – This flag is sent by the client whenever the user wants to store a file
on her machine onto her login. This involves transport of the file object across the
network using a vector. The flag is the 3rd element of the vector of size 4, also
containing the loginname, source file object and the target file object.

Using the flags there can be a proper communication


between the server and the client. The server just waits for the client to send a
Vector typecast as an object. This object is then typecast back into the vector
and fields are analyzed. The server then performs the required action.
Sometimes, the server has to send some information to the client in which case a
vector is used in the reverse direction too – Server to Client.

A graphical frame is created to run as the server


application so that the number of clients can be tracked at any given time and the
respective ports they are working on too can be identified. Whenever a new client
contacts the server, the server displays a message that the server responding at
a local port spawns a thread.

The server typically responds to various tasks given by the


client. The main actions of the server in response to client requests is given
below

• Signing up
The client sends the login password and the flag ‘adduser’. The server
then searches the local directory c:\Database and checks whether the
directory already exists. If it does not exist the server returns a value 1 and
a message is displayed at the client that the required directory has been
created. In case the value 0 is returned the client is asked to give a new
login name.
• Signing in
The client sends the login and the password to the server for verification. If there
does exist such a combination then the confirmation is sent back to the client
and the buttons ‘Read File’ and ‘Save File’ are activated.
• Read File
The client sends the login, password and the flag ‘getlist’. When the server
receives this from the client it checks for the directory, matches the password and
gets all the filenames in the directory and sends them in a vector back to the
client. This list is then displayed in a frame as the list of files in the login. Three
buttons are provided to ask the user what he intends to do Delete, Rename or
Open a file.
• Open file
The client sends the login, file wanted and the flag ‘fileget’. When the server
receives this, it searches for the file in the login and sends the contents of
the file as a string to the client. The client then displays the file in a frame.
• Rename File
The client sends the login, file to be renamed, new file name and the flag
‘renamefile’. When the server receives this, it enters the directory c:\database\

loginname_login and renames the file. If it could be done the integer 1 is returned
to the client and the appropriate message flashed at the client. If the renaming
was unsuccessful, 0 is returned and the message is flashed that renaming could
not be done

• Delete File
The client sends the login, file to be deleted, and the flag ‘delfile’. When the
server receives this, it enters the directory c:\database\ loginname_login and
deletes the file. If it could be done the integer 1 is returned to the client and
the appropriate message flashed at the client. If the renaming was
unsuccessful, 0 is returned and the message is flashed that deletion could
not be performed.
• Save File
The client opens a FileDialog box and the user is prompted to select a file to be
saved from the client hard disc onto the login. The client sends the File object,
login, flag ‘savefile’, and the new name of the file. The object is then stored in the
login directory.
Function of The Client
The Client is essentially an applet so that it can be easily
downloaded on the Internet. The main focus in designing the client is on the
Graphical User Interface. When the Client is first initialized, the control passes to
init(). The init function sets the size of the applet, background color, font color,
layout pattern as well as the Buttons used throughout the applet. ActionListener
() and WindowAdapter () are used extensively so that the applet is sensitive to
mouse movements and actions.

The client contains functions which send the Vector as an


object to the server where the individual elements of the Vector are stripped and

accessed. The methods written in the client are given below with a brief
description about each function.

int getVerified(Object)
This Function sends the login and the password for verification to the server
and returns a value 1 if the login exists and 0 if it does not.

Vector sendReqForList(Vector)
This function sends the request to the server to send the list of files present in
one’s login. The function returns a vector which contains the list of filenames.

String sendFileName(Object)
This function sends the request to the server to send the file while the file name
is typecast to Object and passed as a parameter. The function returns a string
from the server which is the contents of the file. This is valid only for text files.

int sendNewUserInfo(Object)
This function is used to send information regarding a user who wants to sign up
and create a new account. The function returns an integer 0 or 1 which tells if the
creation of a new account was a success or not.

int saveSentFile(Object)
This function asks the server to save the file from the client hard disk onto the
login in the server hard disk. The function takes file object to be saved as an
argument and returns 0 or 1 depending on success of the operation.

int sendFileForDeletion(Object)
This function is used to ask the server to delete the file in userspace. The
filename is sent as the object argument. This too returns 1 or 0 as an argument
depending on success of deletion.

int sendFileForRenaming(Object)
This function is used to ask the server to rename the file in userspace. The
filename is sent as the object argument. This too returns 1 or 0 as an argument
depending on success of renaming.

void sendToServer(Object)
This function is used to send a message to the server that the applet has been
destroyed and that all open streams be closed and sockets closed.
6.SYSTEM TESTING

Testing

1. Unit testing:
Unit testing begins at the vertex of the spiral and concentrates
on each unit of the software as implemented in source code. Initially test
focus on each module individually, assuring that it functions properly as a
unit. Hence the name Unit Testing. Unit testing makes heavy use of white
box testing techniques, exercising specific paths in a module’s control
structure complete coverage and maximum error detection. Unit testing
focuses on verification effort of the smallest unit of software design
module. Using the procedural design description as a guide important
control paths are tested to uncover the errors within the boundary of the
module. The relative complexity of the tests and uncovered errors are
limited by the constrained scope established for unit testing.

Unit testing procedure:


Unit testing is considered as an adjunct to the coding step. After
source-level code has been developed, reviewed and verified for correct syntax,
unit test case design begins. A module is not a standalone program; hence driver
or stub software must be developed for each unit test. Stubs serve to replace
modules that are subordinate to the module to be tested. Drivers and stubs
represent overhead. Unit testing is simplified when a module with high cohesion
is designed. When a module addresses only one function, the number of test
cases is reduced and errors can be more easily predicted and uncovered.

2. Integration Testing:
Integration testing is a systematic technique for constructing
the program structure while conducting tests to uncover errors associated
with interfacing. The objective is to take unit tested modules and build a
program structure that has been dictated by design. There is often
tendency to attempt non-incremental integration, that is, to construct the
program using “big bang” approach. All modules are combined in advance.
The entire program is tested as a whole. A sets of errors are encountered.
Correction is difficult because isolation of causes is complicated by the
vast expanse of the entire program.

Incremental integration is the theme of the big bang approach. The


program is constructed and tested in small segments, where errors are easier to
isolate and correct; interfaces are more likely to be tested completely; and a
systematic approach may be applied.
Different Incremental Integration strategies:
 Top-Down Integration.
 Bottom-Up Integration
 Regression Testing.

3. System Testing:
System testing is actually a series of different tests whose primary
purpose is to fully exercise the computer-based system. Although each test has a
different purpose, all work to verify that all system elements have been properly
integrated and perform allocated functions.

System Testing Types:


 Recovery Testing.
 Security Testing.
 Stress Testing.
 Performance Testing.

Test Cases:

Test case – I:
In HTTP module suppose if u give an invalid URL in the URL address then
we may get an error message indicating that the specified URL is not an valid
one. Similarly if the system is not connected to internet or if net is currently
disconnected then , similar to “Internet Explorer” we may get an Unknown Host
Exception.
Test Case ii:
Similarly suppose if u attempt to send a mail from Source address to
Destination address without connected to Internet U may failed to deliver the
message.
Test Case iii:
The Browser needs the user to specify the server name he wants to
Communicate. For example supposes if the user want to connects to a WEB
server he needs to specify the HTTP protocol . Otherwise we may get a
MalformedURLException
Test Case iv:

Similarly suppose if the user attempts to connect to an Unknown FTP server


the connection may not be established. Even if he attempts with invalid USER
name and PASSWORD he may not be permitted to connect to FTP server.
Test Case v:

In E-Cabinet module unauthorized accesses to files of a particular user is


restricted by providing login and password security facility. If the user enters the
correct login name and its corresponding password then only he has permitted to
access his own files
Test Case vi:
Suppose if the new user want’s to see the files present in his login he may
not be permitted as his login does not contain any files.
Test Case vii :
Suppose if the user made an attempt to create a Directory in Client
Side in FTP module, which is already present then the directory will not be
created instead we may get an error message indicating that the directory
already exists. Even if the memory get expired in that case also the
Directory will not be created.

Test case viii:


Suppose if the user selects an single file not a directory and he passed a
“Remove Directory” command then the file will not deleted as it is not a directory
Test Case ix:

Similarly if the user selects a Directory and he made a “File Deletion”


command then the directory may not be deleted, as the command is “File
Deletion”. Here the file deletion command first checks whether the requested file
is a valid file or not. If it is not a file then the operation will be failed. If the
requested file is a valid file then the file will be deleted
7. SCREEN NAVIGATION

Main screen opened when the user runs the Universal Browser. By default it is the
HTTP Handler that processes the requests for web pages.
Screen opened when the user want to view the History

Maintenance of offline pages


This represents a sample output of the screen opened when the user clicks the view source
button
This represents the mail box opened with attachment of files when the user cliks the mail
Handler button
This represents the HTTP settings internal frame
When the user cliks ‘Favorites’ the above screen showing the Favorite pages and
Best Links pages will be displayed
This is the main window of FTP Handler
This represents the screen opened when the user want to create a Directory in the
Client side
This represents the main screen when the user wants to logon into E-Cabinet
module
This represents the screen opened when ever a new want to Sign up into the server
address space
This window shows the files present in the requested user login
This sample output show’s the window opened when the user save the file into
server Hard disk space
8. LIMITATIONS

1.In order to run the Browser the system on which we are


currently working must have loaded the JAVA language. Also the main
module is not an exe file. We have to run the project through Command
prompt only.

2.when the user want to specify the URL address he must also use the
protocol that the URL need. It means that when ever the user wants to open any web
site he have to give the protocol “http” preceding the URL address in the address bar
of the browser.

3.When providing an virtual address space through E-cabinet module


the user must have to know the IP address of the server he wants to store the files.
9.FUTURE ENHANCEMENTS

Our project “Universal Browser” works as an effective alternative


to most of the browsers available today. Although we have made it possible that
our software communicate with both HTTP and FTP servers it still lacks to
provide communication between two remote hosts(TELNET).The additional
capability of TELNET will make the browser much more efficient and as a single
software that supports all types of communication over a network.
10.CONCLUSION

In the present world, communication is a need for


people all over the world and the evolution of Internet made it
possible successfully. It leads to the question of utilizing the
internet to the fullest possible extent The origin of our project
came from this thought that lead us to create an efficient tool for
browsing the internet.
The project “Universal Browser” is an efficient tool for communication
between several systems connected on a network.
By incorporating a FTP Handler along with the regular HTTP handler we have
successfully made it possible for the users of this software to be able to
communicate with FTP servers along with the regular web servers. The need for
people to have a “virtual hard disk” so that they can access their personnel files
from any where in the world provided they are connected to a network. This
thought leads us to incorporate a feature called “E-cabinet” in our browser. It
effectively registers users to the server and allocates a quota of 5 MB to each of
them along with authorization. Hence it provides the necessary security.

Our selection of JAVA language to implement our browser is driven by


the fact that JAVA is a multipurpose platform independent language that
provides secured communication of data over the network. In addition to this
JAVA boasts a number of features in the form of packages such as
IO,NET,SWING,UTIL etc that made our project possible. By extensively using
above packages we successfully implemented all the features that are discussed
above.
Finally we conclude that users will find Universal Browser as an
efficient and useful alternative to many of the browsers available in the market
today. It is effectively a multipurpose software that can communicate with
different types of servers.

11. REFERENCES
This project is developed by
referring to most of the books that cover the SWING ,NET,UTIL,IO packages
extensively.. Some of those books that might help the users of this software are
listed below.

 BOOKS

• JAVA COMPLETE REFERENCE BY HERBERT SCHILD


• JAVA SWING BY DEITEL&DEITEL
• INTERNET PROGRAMMING BY RAMAKRISHNAN
• JAVA2 BY STEVEN HOLZNER
 WEBSITES

• SUN.COM/JAVATUTORIAL
• JSCAPE.COM
• RFC.COM
• SECUREFTP.COM

You might also like