23-11-2012, 04:38 PM
Web Application Development
Web Application.doc (Size: 144.5 KB / Downloads: 28)
With JSP:
If you have had the opportunity to build web applications using technologies such as Common Gateway Interface (CGI) and servlets, you are accustomed to the idea of writing a program to generate the whole page (the static and the dynamic part) using that same program. If you are looking for a solution in which you can separate the two parts, look no further. Java Server Pages (JSP) are here.
JSP pages allow you to separate front-end presentation from business logic (middle and back-end tiers). It is a great Rapid Application Development (RAD) approach to Web applications. This series of articles provides a hands-on tutorial explaining how to develop modern Web applications for today's and tomorrow's market. This series begins with this article, which explains the concepts and benefits of JSP technology, and then shows you how to utilize this exciting technology, and how to create reusable components for handling forms.
The Dynamic Web
The Web has evolved from a network-based hypermedia distributed information system offering static information to a marketplace for selling and buying goods and services. The increasingly sophisticated applications to enable this marketplace require a technology for presenting dynamic information.
First generation solutions included CGI, which is a mechanism for running external programs through a web server. The problem with CGI scripts is scalability; a new process is created for every request.
Second generation solutions included web server vendors providing plug-ins and APIs for their servers. The problem is that their solutions were specific to their server products. For example, Microsoft provided Active Server Pages (ASP) that made it easier to create dynamic content. However, their solution only worked with Microsoft IIS or Personal Web Server. Therefore, if you wanted to use ASP you had to commit yourself to Microsoft products and you would not be enjoying the freedom of selecting your favorite web server and operating system!
Another second generation technology that is quite popular in enterprise computing is servlets. Servlets make it easier to write server-side applications using Java technology. The problem with either CGI or servlets, however, is that you have to follow the write, compile, and deploy life cycle.
JavaServer Pages (JSP)
The JSP technology is an open, freely available specification developed by Sun Microsystems as an alternative to Microsoft's Active Server Pages (ASP) technology, and a key component of the Java 2 Enterprise Edition (J2EE) specification. Many of the commercially available application servers (such as BEA WebLogic, IBM WebSphere, Live JRun, Orion, and so on) already support JSP technology.
JSP versus ASP
JSP and ASP deliver similar functionality. They both use tags to allow embedded code in an HTML page, session tracking, and database connection. Some of the trivial differences are:
• ASP pages are written in VBScript and JSP pages are written in the Java programming language. Therefore, JSP pages are platform-independent and ASP pages are not.
• JSP pages use JavaBeans technology as the component architecture and ASP pages use ActiveX components.
Software Environment
To run JSP pages, you need a web server with a web container that conforms to JSP and servlet specifications. The web container executes on the web server and manages the execution of all JSP pages and servlets running on that web server. Tomcat 3.2.1 is a complete reference implementation for the Java Servlet 2.2 and JSP 1.1 specifications. Download and install binary versions of Tomcat.
Handling Forms
One of the most common parts of ecommerce applications is an HTML form where the user enters some information such as name and address. Using JSP, the form's data (the information the user enters in the form) gets stored in the request object that is sent from the browser to the JSP container. The request is processed and the result is sent through the response object back to the browser. These two objects are implicitly available to you.
To demonstrate how to handle HTML forms using JSP, here is an example form with two fields: one for name and the other for email. As you can see, the HTML form is defined in a JSP source file. The request.getParameter method is being used to retrieve data from the form into variables created using JSP tags.