1.1. System Overview:: The Proposed System J-SHOP Has Developed To Provide The Several
1.1. System Overview:: The Proposed System J-SHOP Has Developed To Provide The Several
1. INTRODUCTION
1
CSE, MITS, 2008
J-SHOP
2. SYSTEM ANALYSIS
2.1. Existing System
In the existing system the work which is carried out manually and
personally by the Customers, which is time consuming and which have other effects on
the growth of the business. To overcome the above mention problems the project named
as J-SHOP has developed.
In this fast world of Science and Technology, everything is fast and easy.
J-SHOP is an effort to make the online shopping easy and fast. Using this application
you can give order for purchasing different items or goods through the internet easily
without going to the shop. J-SHOP will also provide a GUI interface to all the
Customers of different countries and different regions. By using these application two
categories of people like merchant and customer will get the benefits.
2
CSE, MITS, 2008
J-SHOP
TECHNICAL FEASIBILITY:
A study of resource availability may affect to achieve an acceptable system. The
technical feasibility is frequently the most difficulty area to ensure at this stage, because
objective, functions and performance are somewhat clear anything is possible if the right
assumptions are made. It is essential that the process of analysis and definition can be
conducted in parallel with an assessment of technical feasibility includes resources
availability of the organization, where the project is to be developed and implemented.
By taking these into consideration before developing, the resources availability at this
company was observed. Indeed J-SHOP is a shop that has enough resources (machine
and manpower) to develop any kind of the project for its use and as well as to shop that
has a product. Thus, this project is consideration technically feasible for development.
ECONOIMICAL FEASIBILITY:
An evolution of development cost weighted against the unlimited income or
benefit derived from the developed system. Economically justification is generally the
“Bottom line” consideration of most systems. Economic justification includes a broad
range of concerns that include cost benefit analysis. Cost-Benefit analysis delineates costs
for project development and weights them against tangible and intangible benefits of
system. Regarding the cost and benefits, the project, which is to be developed and
implemented, will give benefits to the shop in terms of man hours when compared to man
hours that are required to record data. It is seen that there is no need of extra hardware
and software for development of this project. Thus this project work is economically
feasible for development in this shop.
3
CSE, MITS, 2008
J-SHOP
OPERATIONAL FEASIBILITY:
Operation feasibility is a consideration about the working of the system after
the installation in the shop. The shop as mentioned in the feasibility analysis has ready
developed, installed many software products. The shop will use this system to maintain
the recruitment of employees.
DFD symbols
Square
4
CSE, MITS, 2008
J-SHOP
Circle or Bubble
Open Rectangle
Context Level
Merchant Merchant
J-SHOP
Customer Customer
5
CSE, MITS, 2008
J-SHOP
Level – 1
1 Login Id
Customer
Id, Pwd, Name, Register
Customer Customer
Mobile Number
Customer
2
Id, Pwd Login Options
Customer Customer
Customer
6
CSE, MITS, 2008
J-SHOP
3
Product Id, Add Product Cost
Customer Customer
Quantity
4
Product Id, Edit Product Cost
Customer Customer
Quantity
5
Product Id Delete Product Cost
Customer Customer
OrderTab, Order_Product
7
CSE, MITS, 2008
J-SHOP
6
Communication Place Order Confirmation
Customer Customer
Address
Transact
7
Order Number Process Order Confirmation
Merchant Merchant
Order_Product
8
CSE, MITS, 2008
J-SHOP
Software Requirements:
Hardware Requirements:
Pentium-IV Processor
40GB Hard Disk space
256MB RAM
9
CSE, MITS, 2008
J-SHOP
SYSTEM DESIGN
UML DIAGRAMS:
The Unified Modeling Language is a standard language for specifying,
visualizing, constructing and documenting the software system and its components. It is a
graphical language, which provides a vocabulary and set of semantics and rules. The
UML focuses on the conceptual and physical representation of the system. It captures the
decisions and understandings about systems that must be constructed. It is used to
understand, design, configure, maintain and control information about the systems.
VISUALIZING:
Through UML we see or visualize on existing system and ultimately we
visualize how the system is going to be after implementation. Unless we think we cannot
implement. UML helps to visualize how the components of the system communicate and
interact with each other.
SPECIFYING:
Specifying means building models that are precise, unambiguous and complete.
UML addresses the specification of all the important Analysis, Design, Implementation
decisions that must be made in developing and deploying a software system.
CONSTRUCTING:
UML models can be directly connected to a variety of programming language
through mapping a model from UML to a programming language like java or c++ or VB.
Forward and reverse Engineering is possible through UML.
10
CSE, MITS, 2008
J-SHOP
DOCUMENTING:
The deliverables of a project apart from coding are some artifacts which are
critical in controlling, measuring and communicating about a system during its
development viz. requirements, architecture, design, source code, project plans, tests,
prototypes, releases etc.
Class Diagram:
11
CSE, MITS, 2008
J-SHOP
12
CSE, MITS, 2008
J-SHOP
13
CSE, MITS, 2008
J-SHOP
14
CSE, MITS, 2008
J-SHOP
4. IMPLEMENTATION
1. Merchant and
2. Customer
1. Merchant:
This module will provide an easy and simple method of updating information
into the database related to the items and categories present in the shop. It includes:
Creating new categories
Editing the exiting categories
Deleting the existing categories
Adding new items to the store
Editing the details of the existing items from the store
Deleting the existing items from the store
16
CSE, MITS, 2008
J-SHOP
17
CSE, MITS, 2008
J-SHOP
Java, whether you love it, or hate it, it's here to stay. Like everyone's favorite
language C, Java has had a major impact on the computing scene. When the history of
computers is written, its name will be up there with the stars.
If you were to choose just one language to learn today, it should be Java.
It's being pushed aggressively by Sun and is growing by leaps and bounds. There are lots
of Java programmers out there and more join the party every day.
Java started out as a bit of an accident. A team under Bill Joy was working
at Sun on a new programming language for embedded applications. Java was originally
expected to work in toasters and fridges, not on modern computers! The initial prognosis
for Java was not good and it was only the rise of the Internet which saved Java from
oblivion. Since then, neither the Net nor Sun nor Java has looked back and all have
grown from strength to strength.
World wide web is an open ended information retrieval system designed to
be used in the distributed environment. This system contains web pages that provide both
information and controls. We can navigate to a new web page in any direction. This is
made possible worth HTML java was meant to be used in distributed environment such
as internet. So java could be easily incorporated into the web system and is capable of
supporting animation graphics , games and other special effect. The web has become
more dynamic and interactive with support of java. We can run a java program on remote
machine over internet with the support of web .
JAVA ENVIRONMENT:
Java environment includes a large no. of tools which are part of the
system known as java development kit (JDK) and hundreds of classes, methods, and
interfaces grouped into packages forms part of java standard library(JSL).
18
CSE, MITS, 2008
J-SHOP
JAVA ARCHITECTURE:
Java architecture provides a portable , robust , high performing
environment for development. Java provides portability by compiling the byte codes for
the java virtual machine which are then interpreted on each platform by the runtime
environment . java also provides stringent compile and runtime checking and automatic
memory management in order to ensure solid code .
PARADIGM OF JAVA:
Dynamic down loading applets(small application programs);
Elimination of flatware phenomenon that is providing those features of a
product that user needs at a time. The remaining features of a product can remain in the
server.
Changing economic model of the software
Up-to-date software availability
Supports network entire computing
Supports CORBA & DCOM
ABOUT HTML:
HTML (hyper text markup language) is a language used to create hyper text
documents that have hyper links embedded in them . it consists of tags embedded in the
text of a document with HTML. We can build web pages or web document s. it is
basically a formatting language and not a programming language. The browser reading
the document interprets mark up tags to help format the document for subsequent display
to a reader. HTML is a language for describing structured documents. HTML is a
19
CSE, MITS, 2008
J-SHOP
platform independent. WWW(world wide web) pages are written using HTML. HTML
tags control in part the representation of the WWW page when view with web browser.
The browser interpretes HTML tags in the web document and displays it. Different
browsers show data differently. Examples of browsers used to be web pages include:
Netscape
Internet Explorer
JAVA SCRIPT:
Java script is a general purpose , prototype based , object oriented scripting
language developed jointly by sun and netscape and is meant for the WWW . it is
designed to be embedded in diverse applications and systems , with out consuming much
memory . java script borrows most of its syntax from java but also inherits from awk and
perl , with some indirect influence from self in its object prototype system.
Java scripts dynamically typed that is programs donot declare variable types, and
the type of variable is unrestricted and can change at runtime . source can be generated at
run time and evaluated against an arbitrary scope. Typical implementations compile by
translating source into a specified byte code format, to check syntax and source
consistency. Note that the availability to generate and interprate programs at runtime
implies the presence of a compiler at runtime.
Java script is a high level scripting language that does not depend on or expose
particular machine representations or operating system services. It provides automatic
storage management, typically using a garbage collector.
FEATURES:
Java script is embedded into HTML documents and is executed with in
them.
Java script is browser dependent
Javascript is an interpreted languaged that can be interpreted by the
browser at run time .
Java script is loosely typed language
Java script is an object based language.
20
CSE, MITS, 2008
J-SHOP
ADVANTAGES:
1. java script can be used for client side application
2. java script provides means to contain multiframe windows for
presentation of the web.
3. java script provides basic data validation before it is sent to the
server. Eg : login and password checking or whether the values entered are correct or
whether all fields in a from are filled and reduced network traffic
4. it creates interactive forms and client side lookup tables .
Rowsets
As its name implies, a rowset encapsulates a set of rows. A rowset may or may
not maintain an open database connection. When a rowset is ‘disconnected’ from its data
source, updates performed on the rowset are propagated to the underlying database us-ing
an optimistic concurrency control algorithm.Rowsets add support to the JDBC API for
the JavaBeans component model. A rowset object is a bean. A rowset implementation
may be serializable. Rowsets can be created at design time and used in conjunction with
other JavaBeans components in a visual builder tool to construct an application.
Other new features
Support for character streams has been added. This means that character data can
be re-trieved and sent to the database as a stream of internationalized Unicode characters.
21
CSE, MITS, 2008
J-SHOP
Servlets are to servers what applets are to browsers. Unlike applets, however, servlets
have no graphical user interface.
Servlets can be embedded in many different servers because the servlet API, which you
use to write servlets, assumes nothing about the server's environment or protocol.
Servlets have become most widely used within HTTP servers; many web servers support
the Servlet API.
22
CSE, MITS, 2008
J-SHOP
Forwarding requests. Servlets can forward requests to other servers and servlets.
Thus servlets can be used to balance load among several servers that mirror the same
content, and to partition a single logical service over several servers, according to task
type or organizational boundaries.
Architecture of the Servlet Package
The javax.servlet package provides interfaces and classes for writing servlets. The
architecture of the package is described below.
The Servlet Interface
The central abstraction in the Servlet API is the Servlet interface. All servlets
implement this interface, either directly or, more commonly, by extending a class that
implements it such as HttpServlet.
23
CSE, MITS, 2008
J-SHOP
The Servlet interface declares, but does not implement, methods that manage the servlet
and its communications with clients. Servlet writers provide some or all of these methods
when developing a servlet.
Client Interaction
When a servlet accepts a call from a client, it receives two objects:
A ServletRequest, which encapsulates the communication from the client to the
server.
A ServletResponse, which encapsulates the communication from the servlet
back to the client.
ServletRequest and ServletResponse are interfaces defined by the javax.servlet
package.
The ServletRequest Interface
The ServletRequest interface allows the servlet access to:
Information such as the names of the parameters passed in by the client, the
protocol (scheme) being used by the client, and the names of the remote host that made
the request and the server that received it.
The input stream, ServletInputStream. Servlets use the input stream to get data
from clients that use application protocols such as the HTTP POST and PUT methods.
24
CSE, MITS, 2008
J-SHOP
Interfaces that extend ServletRequest interface allow the servlet to retrieve more
protocol-specific data. For example, the HttpServletRequest interface contains
methods for accessing HTTP-specific header information.
The ServletResponse Interface
The ServletResponse interface gives the servlet methods for replying to the client. It:
Allows the servlet to set the content length and MIME type of the reply.
25
CSE, MITS, 2008
J-SHOP
PrintWriter out;
String title = "Simple Servlet Output";
// set content type and other response header fields first
response.setContentType("text/html");
// then write the data of the response
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from SimpleServlet.");
out.println("</BODY></HTML>");
out.close();
}}
Servlet Lifecycle
Each servlet has the same life cycle:
1. A server loads and initializes the servlet.
2. The servlet handles zero or more client requests.
3. The server removes the servlet
26
CSE, MITS, 2008
J-SHOP
Initializing a Servlet
When a server loads a servlet, the server runs the servlet's init method. Initialization
completes before client requests are handled and before the servlet is destroyed.
Even though most servlets are run in multi-threaded servers, servlets have no
concurrency issues during servlet initialization. The server calls the init method once,
when the server loads the servlet, and will not call the init method again unless the server
is reloading the servlet. The server can not reload a servlet until after the server has
destroyed the servlet by calling the destroy method.
27
CSE, MITS, 2008
J-SHOP
If, for some reason, you need to get the parameter names, use the getParameterNames
method.
Destroying a Servlet
Servlets run until the server are destroys them, for example at the request of a system
administrator. When a server destroys a servlet, the server runs the servlet's destroy
method. The method is run once; the server will not run that servlet again until after the
server reloads and reinitializes the servlet.
When the destroy method runs, another thread might be running a service request. The
Handling Service Threads at Servlet Termination section shows you how to provide a
clean shutdown when there could be long-running threads still running service requests.
28
CSE, MITS, 2008
J-SHOP
server calls the destroy method. You are responsible for making sure those threads
complete. The next section shows you how.
The destroy method shown above expects all client interactions to be completed when
the destroy method is called, because the servlet has no long-running operations.
Make sure the compiler will be able to find the jws.jar file. The jws.jar file
contains Java Web Server's implementation of the Servlet API. Ensuring the compiler can
find the file is easy to do using the cp option to the compiler, as we do below. (You can
also modify the classpath environment variable temporarily from a command line or
permanently in your system setttings.)
Use javac, located in the Java Web Server's jre/bin directory, to compile
the .java file. You'll need to copy the resulting .class file to the servlets directory of the
Java Web Server so the web server will automatically find it. To skip the copying step,
simply invoke javac with the -d option to direct the resulting .class file to the target
directory.
For example, the following command compiles MyFirst.java and stores the resulting
MyFirst.class file in the servlets directory:
javac -cp server_root/lib/jws.jar -d server_root/servlets MyFirst.java
where server_root is the directory of the installed Java Web Server.
Install the servlet
The process for installing a servlet into a web server varies from web server to webserver.
For the Java Web Server, the procedure is as follows:
29
CSE, MITS, 2008
J-SHOP
4. Click the Servlets button, then select the Add entry in the list in the lefthand pane.
You should now see the Add a New Servlet fields in the righthand pane.
5. Fill in the fields as follows:
1. Servlet Name: Choose any name you like, it need not be related to the filename.
This will be the name used to invoke the servlet. We'll use FirstServlet.
2. Servlet Class: Provide the actual name of the servlet class, not file, you created --
for this example the real name is MyFirst.
3. Click the Add button and you will see your servlet name appear in the list of
servlets in the lefthand pane under Configure. The righthand pane will have
changed to two tabbed panels -- Configuration and Properties. We won't need
these for our simple example so simply close the window.
AN OVERVIEW OF JSP:
Java Server Pages technology is the powerful java technology in the J2EE platform
for building and maintaining the applications containing dynamic web contents such as
HTML, DHTML, XHTML, XHTML, and XML. The Java Server Pages that create
dynamic content easily but with maximum power and flexibility.
The Java server Pages technology provides a textual description for the creation of a
response from a request. It architecture enables the separation of content generation from
the content presentation. Java Server Pages offers proven portability, open standards, and a
mature re-usable component model.
Access Models:
30
CSE, MITS, 2008
J-SHOP
A Java Server Pages file may be accessed in at least two different ways:
1. A client request comes directly into a Java Server Page.
In this scenario, suppose the page accesses reusable Java Bean components that
perform particular well-defined computations like accessing a database. The results of the
Bean’s computations, called result sets are stored within the Bean as properties. The page
uses such Beans to generate dynamic content and present back to the client.
A JSP page is a text-based document that contains two types of text: static
template data, which can be expressed in any text-based format, such as HTML,
SVG, WML, and XML; and JSP elements, which construct dynamic content.
A JSP page services requests as a servlet. Thus, the life cycle and many of the
capabilities of JSP pages (in particular the dynamic aspects) are determined by
Java Servlet technology.
31
CSE, MITS, 2008
J-SHOP
During the translation phase, each type of data in a JSP page is treated differently.
Template data is transformed into code that will emit the data into the stream that
returns data to the client. JSP elements are treated as follows:
Directives are used to control how the Web container translates and
executes the JSP page.
Scripting elements are inserted into the JSP page's servlet class. See JSP
Scripting Elements for details.
Elements of the form <jsp:XXX ... /> are converted into method
calls to JavaBeans components or invocations of the Java Servlet API.
For a JSP page named pageName, the source for a JSP page's servlet is kept in
the file
J2EE_HOME/repository/host/web/
context_root/_0002fpageName_jsp.java
For example, the source for the index page (named index.jsp) for the date
localization example discussed at the beginning of the chapter would be named
J2EE_HOME/repository/host/web/date/_0002findex_jsp
.java
Both the translation and compilation phases can yield errors that are only
observed when the page is requested for the first time. If an error occurs while the
page is being translated (for example, if the translator encounters a malformed
JSP element), the server will return a ParseException, and the servlet class
source file will be empty or incomplete. The last incomplete line will give a
pointer to the incorrect JSP element.
32
CSE, MITS, 2008
J-SHOP
If an error occurs while the JSP page is being compiled (for example, there is a
syntax error in a scriptlet), the server will return a JasperException and a
message that includes the name of the JSP page's servlet and the line where the
error occurred.
Once the page has been translated and compiled, the JSP page's servlet for the
most part follows the servlet life cycle described in the section Servlet Life Cycle:
1. If an instance of the JSP page's servlet does not exist, the container:
a. Loads the JSP page's servlet class
b. Instantiates an instance of the servlet class
c. Initializes the servlet instance by calling the jspInit method
If the container needs to remove the JSP page's servlet, it calls the jspDestroy
method.
Execution :
You can control various JSP page execution parameters using by page
directives. The directives that pertain to buffering output and handling errors are
discussed here. Other directives are covered in the context of specific page
authoring tasks throughout the chapter.
Buffering :
33
CSE, MITS, 2008
J-SHOP
A larger buffer allows more content to be written before anything is actually sent
back to the client, thus providing the JSP page with more time to set appropriate
status codes and headers or to forward to another Web resource. A smaller buffer
decreases server memory load and allows the client to start receiving data more
quickly.
Handling Errors :
Any number of exceptions can arise when a JSP page is executed. To specify that
the Web container should forward control to an error page if an exception occurs,
include the following page directive at the beginning of your JSP page:
Note: You can also define error pages for the WAR that contains a JSP page. If
error pages are defined for both the WAR and a JSP page, the JSP page's error
page takes precedence.
34
CSE, MITS, 2008
J-SHOP
Stephanie Bodoff :
The standard JSP tags for invoking operations on JavaBeans components and
performing request dispatching simplify JSP page development and maintenance.
JSP technology also provides a mechanism for encapsulating other types of
dynamic functionality in custom tags, which are extensions to the JSP language.
Custom tags are usually distributed in the form of a tag library, which defines a
set of related custom tags and contains the objects that implement the tags.
Some examples of tasks that can be performed by custom tags include operations
on implicit objects, processing forms, accessing databases and other enterprise
services such as e-mail and directories, and performing flow control. JSP tag
libraries are created by developers who are proficient at the Java programming
language and expert in accessing data and other services, and are used by Web
application designers who can focus on presentation issues rather than being
concerned with how to access enterprise services. As well as encouraging division
of labor between library developers and library users, custom tags increase
productivity by encapsulating recurring tasks so that they can be reused across
more than one application.
Tag libraries are receiving a great deal of attention in the JSP technology
community
35
CSE, MITS, 2008
J-SHOP
Using Tags :
This section describes how a page author specifies that a JSP page is using a tag
library and introduces the different types of tags.
You declare that a JSP page will use tags defined in a tag library by including a
taglib directive in the page before any custom tag is used:
The uri attribute refers to a URI that uniquely identifies the tag library descriptor
(TLD), described in the section Tag Library Descriptors. This URI can be direct
or indirect. The prefix attribute defines the prefix that distinguishes tags
defined by a given tag library from those provided by other tag libraries.
Tag library descriptor file names must have the extension .tld. TLD files are
stored in the WEB-INF directory of the WAR or in a subdirectory of WEB-INF.
You can reference a TLD directly and indirectly.
36
CSE, MITS, 2008
J-SHOP
This taglib directive uses a short logical name to indirectly reference the TLD:
1. Select Bookstore3WAR.
Types of Tags :
JSP custom tags are written using XML syntax. They have a start tag and end tag,
and possibly a body:
<tt:tag>
body
</tt:tag>
37
CSE, MITS, 2008
J-SHOP
<tt:tag />
Simple Tags :
<tt:simple />
A custom tag can have attributes. Attributes are listed in the start tag and have the
syntax attr="value". Attribute values serve to customize the behavior of a
custom tag just as parameters are used to customize the behavior of a method.
You specify the types of a tag's attributes in a tag library descriptor (see Tag
Library Descriptors).
You can set an attribute value from a String constant or a runtime expression.
The conversion process between the constants and runtime expressions and
attribute types follows the rules described for JavaBeans component properties in
Setting JavaBeans Component Properties.
The attributes of the Struts logic:present tag determine whether the body of
the tag is evaluated. In the following example, an attribute specifies a request
parameter named Clear:
<logic:present parameter="Clear">
38
CSE, MITS, 2008
J-SHOP
<logic:iterate collection="<%=bookDB.getBooks()%>"
id="book" type="database.BookDetails">
A custom tag can contain custom and core tags, scripting elements, HTML text,
and tag-dependent body content between the start and end tag.
<logic:present parameter="Clear">
<% cart.clear(); %>
<font color="#ff0000" size="+2"><strong>
You just cleared your shopping cart!
</strong><br> <br></font>
</logic:present>
As shown in the last two sections, it is possible to pass a given piece of data as an
attribute of the tag or as the tag's body. Generally speaking, any data that is a
simple string or can be generated by evaluating a simple expression is best passed
as an attribute.
39
CSE, MITS, 2008
J-SHOP
A custom tag can define a variable that can be used in scripts within a page. The
following example illustrates how to define and use a scripting variable that
contains an object returned from a JNDI lookup. Examples of such objects
include enterprise beans, transactions, databases, environment entries, and so on:
In the Duke's Bookstore application, several pages use bean-oriented tags from
Struts to define scripting variables. For example, bookdetails.jsp uses the
bean:parameter tag to create the bookId scripting variable and set it to the
value of the bookId request parameter. The jsp:setProperty statement
also sets the bookId property of the bookDB object to the value of the bookId
request parameter. The bean:define tag retrieves the value of the bookstore
database property bookDetails and defines the result as the scripting variable
book:
Cooperating Tags :
40
CSE, MITS, 2008
J-SHOP
Customer tags can cooperate with each other through shared objects. In
the following example, tag1 creates an object called obj1, which is then reused
by tag2.
<tt:outerTag>
<tt:innerTag />
</tt:outerTag>
Defining Tags :
This section describes the properties of tag handlers and TLDs and explains how
to develop tag handlers and library descriptor elements for each type of tag
introduced in the previous section.
Tag Handlers :
41
CSE, MITS, 2008
J-SHOP
Tag handler methods defined by the Tag and BodyTag interfaces are called by
the JSP page's servlet at various points during the evaluation of the tag. When the
start tag of a custom tag is encountered, the JSP page's servlet calls methods to
initialize the appropriate handler and then invokes the handler's doStartTag
method. When the end tag of a custom tag is encountered, the handler's
doEndTag method is invoked. Additional methods are invoked in between when
a tag handler needs to interact with the body of the tag. For further information,
see How Is a Tag Handler Invoked?. In order to provide a tag handler
implementation, you must implement the methods, summarized in Table 13-1,
that are invoked at various stages of processing the tag.
A tag handler has access to an API that allows it to communicate with the JSP
page. The entry point to the API is the page context object
(javax.servlet.jsp.PageContext), through which a tag handler can
retrieve all the other implicit objects (request, session, and application) accessible
from a JSP page.
Implicit objects can have named attributes associated with them. Such attributes
are accessed using [set|get]Attribute methods.
If the tag is nested, a tag handler also has access to the handler (called the parent)
associated with the enclosing tag.
42
CSE, MITS, 2008
J-SHOP
For each tag attribute, you must define a property and get and set methods that
conform to the JavaBeans architecture conventions in the tag handler. For
example, the tag handler for the Struts logic:present tag,
<logic:present parameter="Clear">
Note that if your attribute is named id and your tag handler inherits from the
TagSupport class, you do not need to define the property and set and get methods
because these are already defined by TagSupport.
A tag attribute whose value is a String can name an attribute of one of the implicit
objects available to tag handlers. An implicit object attribute would be accessed
by passing the tag attribute value to the [set|get]Attribute method of the implicit
object. This is a good way to pass scripting variable names to a tag handler where
they are associated with objects stored in the page context (see Tags That Define
Scripting Variables).
43
CSE, MITS, 2008
J-SHOP
Attribute Element
For each tag attribute, you must specify whether the attribute is required, whether
the value can be determined by an expression, and, optionally, the type of the
attribute in an attribute element. For static values the type is always
java.lang.String. If the rtexprvalue element is true or yes, then the type element
defines the return type expected from any expression specified as the value of the
attribute.
<attribute>
<name>attr1</name>
<required>true|false|yes|no</required>
<rtexprvalue>true|false|yes|no</rtexprvalue>
<type>fully_qualified_type</type>
</attribute>
If a tag attribute is not required, a tag handler should provide a default value.
The tag element for the logic:present tag declares that the parameter attribute is
not required (because the tag can also test for the presence of other entities such
as bean properties) and that its value can be set by a runtime expression.
<tag>
<name>present</name>
<tag-class>org.apache.struts.taglib.
logic.PresentTag</tag-class>
<body-content>JSP</body-content>
...
<attribute>
<name>parameter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
44
CSE, MITS, 2008
J-SHOP
</attribute>
...
</tag>
Attribute Validation
The documentation for a tag library should describe valid values for tag attributes.
When a JSP page is translated, a Web container will enforce any constraints
contained in the TLD element for each attribute.
The attributes passed to a tag can also be validated at translation time with the
isValid method of a class derived from TagExtraInfo. This class is also used to
provide information about scripting variables defined by the tag (see Tags That
Define Scripting Variables).
The isValid method is passed the attribute information in a TagData object, which
contains attribute-value tuples for each of the tag's attributes. Since the validation
occurs at translation time, the value of an attribute that is computed at request
time will be set to TagData.REQUEST_TIME_VALUE.
The tag <tt:twa attr1="value1"/> has the following TLD attribute element:
<attribute>
<name>attr1</name>
<required>true</required>
<rtexprvalue>true</a>
</attribute>
This declaration indicates that the value of attr1 can be determined at runtime.
The following isValid method checks that the value of attr1 is a valid Boolean
value. Note that since the value of attr1 can be computed at runtime, isValid must
check whether the tag user has chosen to provide a runtime value.
45
CSE, MITS, 2008
J-SHOP
Tag Handlers
Cooperating Tags
Tags cooperate by sharing objects. JSP technology supports two styles of object
sharing. The first style requires that a shared object be named and stored in the
page context (one of the implicit objects accessible to both JSP pages and tag
handlers). To access objects created and named by another tag, a tag handler uses
the pageContext.getAttribute(name, scope) method.
46
CSE, MITS, 2008
J-SHOP
In the second style of object sharing, an object created by the enclosing tag
handler of a group of nested tags is available to all inner tag handlers. This form
of object sharing has the advantage that it uses a private namespace for the
objects, thus reducing the potential for naming conflicts.
To access an object created by an enclosing tag, a tag handler must first obtain its
enclosing tag with the static method TagSupport.findAncestorWithClass(from,
class) or the TagSupport.getParent method. The former method should be used
when a specific nesting of tag handlers cannot be guaranteed. Once the ancestor
has been retrieved, a tag handler can access any statically or dynamically created
objects. Statically created objects are members of the parent. Private objects can
also be created dynamically. Such objects can be stored in a tag handler with the
setValue method and retrieved with the getValue method.
The following example illustrates a tag handler that supports both the named and
private object approaches to sharing objects. In the example, the handler for a
query tag checks whether an attribute named connection has been set in the
doStartTag method. If the connection attribute has been set, the handler retrieves
the connection object from the page context. Otherwise, the tag handler first
retrieves the tag handler for the enclosing tag and then retrieves the connection
object from that handler.
47
CSE, MITS, 2008
J-SHOP
(ConnectionTag)findAncestorWithClass(this,
ConnectionTag.class);
if (ancestorTag == null) {
throw new JspTagException("A query without
a connection attribute must be nested
within a connection tag.");
}
connection = ancestorTag.getConnection(); } }}
The query tag implemented by this tag handler could be used in either of the
following ways:
The TLD for the tag handler must indicate that the connection attribute is optional
with the following declaration:
<tag>
...
<attribute>
<name>connection</name>
<required>false</required>
48
CSE, MITS, 2008
J-SHOP
</attribute>
</tag>
Advantages of JSP:
While JSP is extremely powerful and capable of creating complex web
applications, it is also very easy to learn. JSP offers the following advantages over other
server-side technologies.
5. TESTING
5.1 Testing Fundamentals
TESTING METHOD:
TESTING OBJECTIVES:
49
CSE, MITS, 2008
J-SHOP
A good test case is one that has a high probability of finding a yet undiscovered
error.
A successful test is one that uncovers yet undiscovered error.
Testing cannot show the absence of defects, it can show that software errors are
present.
TESTING PRINCIPLES:
The term white box (or glass box) indicates that testing is done with
knowledge of the code used to execute certain functionality. For this reason, a
programmer is usually required to perform white box tests. Often, multiple programmers
will write tests based on certain code, so as to gain varying perspectives on possible
outcomes.
50
CSE, MITS, 2008
J-SHOP
The term black box indicates that the tester does not examine the internal
implementation of the program being executed. For this reason, the programmer does not
normally carry out black box testing.
51
CSE, MITS, 2008
J-SHOP
6. RESULTS
52
CSE, MITS, 2008
J-SHOP
Home page
53
CSE, MITS, 2008
J-SHOP
54
CSE, MITS, 2008
J-SHOP
55
CSE, MITS, 2008
J-SHOP
56
CSE, MITS, 2008
J-SHOP
57
CSE, MITS, 2008
J-SHOP
58
CSE, MITS, 2008
J-SHOP
59
CSE, MITS, 2008
J-SHOP
60
CSE, MITS, 2008
J-SHOP
61
CSE, MITS, 2008
J-SHOP
62
CSE, MITS, 2008
J-SHOP
63
CSE, MITS, 2008
J-SHOP
64
CSE, MITS, 2008
J-SHOP
65
CSE, MITS, 2008
J-SHOP
66
CSE, MITS, 2008
J-SHOP
Payment form
67
CSE, MITS, 2008
J-SHOP
68
CSE, MITS, 2008
J-SHOP
69
CSE, MITS, 2008
J-SHOP
70
CSE, MITS, 2008
J-SHOP
71
CSE, MITS, 2008
J-SHOP
72
CSE, MITS, 2008
J-SHOP
73
CSE, MITS, 2008
J-SHOP
74
CSE, MITS, 2008
J-SHOP
75
CSE, MITS, 2008
J-SHOP
This system is implemented fulfilling all the client requirements. The interfaces
designed for the system is very user friendly and attractive. It has successfully
implemented the shopping transactions like adding the categories and products and
maintaining them, placing orders, managing carts etc., successfully as per the client
requirement. The system has successfully passed the testing at the development site and
is under the testing phase in the presence of the client. The system is waiting for the client
response.
76
CSE, MITS, 2008
J-SHOP
8. REFERENCES
77
CSE, MITS, 2008