Java Tecnlogies Web Application

Embed Size (px)

Citation preview

  • 8/8/2019 Java Tecnlogies Web Application

    1/44

    Introduction

    Web application

    In software engineering, a web application orwebapp [1] is an applicationthat is accessed via web browserover anetwork such as the Internet or an intranet. It is also a computer software application that is coded in a browser-supported language (such as HTML, JavaScript, Java, etc.) and reliant on a common web browser to render the

    applicationexecutable.

    Web applications are popular due to the ever presence of a client, sometimes called athin client. The ability to update

    and maintain web applications without distributing and installing software on potentially thousands of client computersis a key reason for their popularity. Common web applications include webmail, online retail sales, online auctions,wikisand many other functions.

    History

    In earlier types ofclient-server computing, each application had its own client program which served as its userinterface and had to be separately installed on each user's personal computer. An upgrade to the server part of theapplication would typically require an upgrade to the clients installed on each user workstation, adding to the support

    cost and decreasingproductivity.

    In contrast, web applications use web documents written in a standard format such as HTML (and more recently

    XHTML), which are supported by a variety of web browsers.

    Generally, each individual web page is delivered to the client as a static document, but the sequence of pages canprovide an interactive experience, as user input is returned through web formelements embedded in the page markup.During the session, the web browser interprets and displays the pages, and acts as the universalclient for any web

    application.

    In 1995, Netscape introduced a client-side scripting called JavaScript, which allowed programmers to add somedynamic elements to the user interface that ran on the client side. Until then, all the data had to be sent to the server for

    processing, and the results were delivered through static HTML pages sent back to the client.

    In 1996, Macromedia introducedFlash, a vector animation player that could be added to browsers as apluginto embedanimations on the web pages. It allowed the use of a scripting language to program interactions on the client side with

    no need to communicate with the server.

    In 1999, the "web application" concept was introduced in the Java language in the Servlet Specification version 2.2.

    [2.1?]. [1][2] At that time both JavaScriptandXMLhad already been developed, butAJAXhad not still been coined andthe XMLHttpRequest object had only been recently introduced on Internet Explorer 5 as an ActiveX object. [3]

    In 2004,Web 2.0was coined, and it was proposed to use the Web as a platform, [4]as opposed to simply developingapplications that used Internet to communicate with the server.

    In 2005, AJAX was coined, and applications like Gmailstarted to make their client sides more and more interactive.

    Interface

    Webconvergeroperating systemprovides an interface for web applications.

    The web interface places very few limits on client functionality. Through Java,JavaScript, DHTML,Flashand other

    technologies, application-specific methods such as drawing on the screen, playing audio, and access to the keyboard

    http://en.wikipedia.org/wiki/Software_engineeringhttp://en.wikipedia.org/wiki/Software_engineeringhttp://en.wikipedia.org/wiki/Web_application#cite_note-jgurufaq-0%23cite_note-jgurufaq-0http://en.wikipedia.org/wiki/Web_application#cite_note-jgurufaq-0%23cite_note-jgurufaq-0http://en.wikipedia.org/wiki/Application_softwarehttp://en.wikipedia.org/wiki/Application_softwarehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Internethttp://en.wikipedia.org/wiki/Internethttp://en.wikipedia.org/wiki/Internethttp://en.wikipedia.org/wiki/Intranethttp://en.wikipedia.org/wiki/Intranethttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Java_(programming_language)http://en.wikipedia.org/wiki/Java_(programming_language)http://en.wikipedia.org/wiki/Java_(programming_language)http://en.wikipedia.org/wiki/Executablehttp://en.wikipedia.org/wiki/Executablehttp://en.wikipedia.org/wiki/Executablehttp://en.wikipedia.org/wiki/Client_(computing)http://en.wikipedia.org/wiki/Client_(computing)http://en.wikipedia.org/wiki/Thin_clienthttp://en.wikipedia.org/wiki/Thin_clienthttp://en.wikipedia.org/wiki/Webmailhttp://en.wikipedia.org/wiki/Retail_saleshttp://en.wikipedia.org/wiki/Retail_saleshttp://en.wikipedia.org/wiki/Retail_saleshttp://en.wikipedia.org/wiki/Online_auctionhttp://en.wikipedia.org/wiki/Online_auctionhttp://en.wikipedia.org/wiki/Wikihttp://en.wikipedia.org/wiki/Wikihttp://en.wikipedia.org/wiki/Client-serverhttp://en.wikipedia.org/wiki/Client-serverhttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Technical_supporthttp://en.wikipedia.org/wiki/Productivityhttp://en.wikipedia.org/wiki/Productivityhttp://en.wikipedia.org/wiki/Web_documenthttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/XHTMLhttp://en.wikipedia.org/wiki/Formhttp://en.wikipedia.org/wiki/Formhttp://en.wikipedia.org/wiki/Client-side_scriptinghttp://en.wikipedia.org/wiki/Client-side_scriptinghttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Pluginhttp://en.wikipedia.org/wiki/Pluginhttp://en.wikipedia.org/wiki/Web_application#cite_note-jgurufaq-0%23cite_note-jgurufaq-0http://en.wikipedia.org/wiki/Web_application#cite_note-1%23cite_note-1http://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/AJAXhttp://en.wikipedia.org/wiki/AJAXhttp://en.wikipedia.org/wiki/AJAXhttp://en.wikipedia.org/wiki/Web_application#cite_note-apple-2%23cite_note-apple-2http://en.wikipedia.org/wiki/Web_2.0http://en.wikipedia.org/wiki/Web_2.0http://en.wikipedia.org/wiki/Web_2.0http://en.wikipedia.org/wiki/Web_application#cite_note-3%23cite_note-3http://en.wikipedia.org/wiki/Web_application#cite_note-3%23cite_note-3http://en.wikipedia.org/wiki/Web_application#cite_note-3%23cite_note-3http://en.wikipedia.org/wiki/Gmailhttp://en.wikipedia.org/wiki/Gmailhttp://en.wikipedia.org/wiki/Webconvergerhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Java_(Sun)http://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/DHTMLhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Software_engineeringhttp://en.wikipedia.org/wiki/Web_application#cite_note-jgurufaq-0%23cite_note-jgurufaq-0http://en.wikipedia.org/wiki/Application_softwarehttp://en.wikipedia.org/wiki/Web_browserhttp://en.wikipedia.org/wiki/Internethttp://en.wikipedia.org/wiki/Intranethttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Java_(programming_language)http://en.wikipedia.org/wiki/Executablehttp://en.wikipedia.org/wiki/Client_(computing)http://en.wikipedia.org/wiki/Thin_clienthttp://en.wikipedia.org/wiki/Webmailhttp://en.wikipedia.org/wiki/Retail_saleshttp://en.wikipedia.org/wiki/Online_auctionhttp://en.wikipedia.org/wiki/Wikihttp://en.wikipedia.org/wiki/Client-serverhttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/Personal_computerhttp://en.wikipedia.org/wiki/Technical_supporthttp://en.wikipedia.org/wiki/Productivityhttp://en.wikipedia.org/wiki/Web_documenthttp://en.wikipedia.org/wiki/HTMLhttp://en.wikipedia.org/wiki/XHTMLhttp://en.wikipedia.org/wiki/Formhttp://en.wikipedia.org/wiki/Client-side_scriptinghttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Pluginhttp://en.wikipedia.org/wiki/Web_application#cite_note-jgurufaq-0%23cite_note-jgurufaq-0http://en.wikipedia.org/wiki/Web_application#cite_note-1%23cite_note-1http://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/XMLhttp://en.wikipedia.org/wiki/AJAXhttp://en.wikipedia.org/wiki/Web_application#cite_note-apple-2%23cite_note-apple-2http://en.wikipedia.org/wiki/Web_2.0http://en.wikipedia.org/wiki/Web_application#cite_note-3%23cite_note-3http://en.wikipedia.org/wiki/Gmailhttp://en.wikipedia.org/wiki/Webconvergerhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Java_(Sun)http://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/DHTMLhttp://en.wikipedia.org/wiki/Adobe_Flash
  • 8/8/2019 Java Tecnlogies Web Application

    2/44

    and mouse are all possible. Many services have worked to combine all of these into a more familiar interface that

    adopts the appearance of an operating system. General purpose techniques such asdrag and drop are also supported bythese technologies. Web developers often use client-side scripting to add functionality, especially to create an

    interactive experience that does not require page reloading (which many users find disruptive)[citation needed]. Recently,technologies have been developed to coordinate client-side scripting with server-side technologies such as PHP.Ajax, a

    web development technique using a combination of various technologies, is an example of technology which creates amore interactive experience.

    Technical considerations

    A significant advantage of building web applications to support standard browser features is that they should perform

    as specified regardless of the operating system or OS version installed on a given client. Rather than creating clients forMS Windows,Mac OS X,Linux, and otheroperating systems, the application can be written once and deployed almost

    anywhere. However, inconsistent implementations of the HTML, CSS, DOM and other browser specifications cancause problems in web application development and support. Additionally, the ability of users to customize many ofthe display settings of their browser (such as selecting different font sizes, colors, and typefaces, or disabling scriptingsupport) can interfere with consistent implementation of a web application.

    Another approach is to useAdobe Flash orJava appletsto provide some or all of the user interface. Since most webbrowsers include support for these technologies (usually through plug-ins), Flash- or Java-based applications can beimplemented with much of the same ease of deployment. Because they allow the programmer greater control over the

    interface, they bypass many browser-configuration issues, although incompatibilities between Java or Flashimplementations on the client can introduce different complications. Because of their architectural similarities totraditional client-server applications, with a somewhat "thick" client, there is some dispute over whether to call systems

    of this sort "web applications"; an alternative term is "Rich Internet Application" (RIA).

    Structure

    Applications are usually broken into logical chunks called "tiers", where every tier is assigned a role.[5] Traditionalapplications consist only of 1 tier, which resides on the client machine, but web applications lend themselves to a n-

    tiered approach by nature.[5] Though many variations are possible, the most common structure is the three-tieredapplication.[5]In its most common form, the three tiers are calledpresentation, application andstorage, in this order. A

    web browser is the first tier (presentation), an engine using some dynamic Web content technology (such as ASP,ASP.NET, CGI, ColdFusion, JSP/Java, PHP, Perl, Python, Ruby on Rails orStruts2) is the middle tier (application

    logic), and a database is the third tier (storage).[5]The web browser sends requests to the middle tier, which services

    them by making queries and updates against the database and generates a user interface.

    For more complex applications, a 3-tier solution may fall short, and you may need a n-tiered approach, where thegreatest benefit is breaking the business logic, which resides on the application tier, into a more fine-grained model. [5]

    For example, creating a separate business logic tier. Or adding an integration tier that separates the data tier from therest of tiers by providing an easy-to-use interface to access the data.[5]For example, you would access the client data by

    calling a "list_clients()" function instead of making a SQL query directly against the client table on the database. Thatallows to replace the underlying database without changing the other tiers.[5]

    There are some who view a web application as a two-tier architecture. This can be a "smart" client that performs all thework and queries a "dumb" server, or a "dumb" client that relies on a "smart" server. [5]The client would handle the

    presentation tier, the server would have the database (storage tier), and the business logic (application tier) would be onone of them or on both. [5]While this increases the scalability of the applications and separates the display and the

    database, it still doesn't allow for true specialization of layers, so most applications will outgrow this model.[5]

    Business use

    An emerging strategy for application software companies is to provide web access to software previously distributed aslocal applications. Depending on the type of application, it may require the development of an entirely different

    browser-based interface, or merely adapting an existing application to use different presentation technology. Theseprograms allow the user to pay a monthly or yearly fee for use of a software application without having to install it on a

    local hard drive. A company which follows this strategy is known as an application service provider(ASP), and ASPsare currently receiving much attention in the software industry.

    http://en.wikipedia.org/wiki/Drag_and_drophttp://en.wikipedia.org/wiki/Drag_and_drophttp://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Ajax_(programming)http://en.wikipedia.org/wiki/Ajax_(programming)http://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Mac_OS_Xhttp://en.wikipedia.org/wiki/Mac_OS_Xhttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/HyperText_Markup_Languagehttp://en.wikipedia.org/wiki/HyperText_Markup_Languagehttp://en.wikipedia.org/wiki/Cascading_Style_Sheetshttp://en.wikipedia.org/wiki/Document_Object_Modelhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Java_applethttp://en.wikipedia.org/wiki/Java_applethttp://en.wikipedia.org/wiki/Java_applethttp://en.wikipedia.org/wiki/Rich_Internet_Applicationhttp://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Three-tier_(computing)http://en.wikipedia.org/wiki/Three-tier_(computing)http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Active_Server_Pageshttp://en.wikipedia.org/wiki/Active_Server_Pageshttp://en.wikipedia.org/wiki/ASP.NEThttp://en.wikipedia.org/wiki/ASP.NEThttp://en.wikipedia.org/wiki/Common_Gateway_Interfacehttp://en.wikipedia.org/wiki/Common_Gateway_Interfacehttp://en.wikipedia.org/wiki/ColdFusionhttp://en.wikipedia.org/wiki/Java_Servlethttp://en.wikipedia.org/wiki/Java_Servlethttp://en.wikipedia.org/wiki/Java_Servlethttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Perlhttp://en.wikipedia.org/wiki/Perlhttp://en.wikipedia.org/wiki/Python_(programming_language)http://en.wikipedia.org/wiki/Python_(programming_language)http://en.wikipedia.org/wiki/Ruby_on_Railshttp://en.wikipedia.org/wiki/Ruby_on_Railshttp://en.wikipedia.org/wiki/Ruby_on_Railshttp://en.wikipedia.org/wiki/Struts2http://en.wikipedia.org/wiki/Struts2http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Application_service_providerhttp://en.wikipedia.org/wiki/Application_service_providerhttp://en.wikipedia.org/wiki/Drag_and_drophttp://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Ajax_(programming)http://en.wikipedia.org/wiki/Microsoft_Windowshttp://en.wikipedia.org/wiki/Mac_OS_Xhttp://en.wikipedia.org/wiki/Linuxhttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/HyperText_Markup_Languagehttp://en.wikipedia.org/wiki/Cascading_Style_Sheetshttp://en.wikipedia.org/wiki/Document_Object_Modelhttp://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Java_applethttp://en.wikipedia.org/wiki/Rich_Internet_Applicationhttp://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Three-tier_(computing)http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Active_Server_Pageshttp://en.wikipedia.org/wiki/ASP.NEThttp://en.wikipedia.org/wiki/Common_Gateway_Interfacehttp://en.wikipedia.org/wiki/ColdFusionhttp://en.wikipedia.org/wiki/Java_Servlethttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Perlhttp://en.wikipedia.org/wiki/Python_(programming_language)http://en.wikipedia.org/wiki/Ruby_on_Railshttp://en.wikipedia.org/wiki/Struts2http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Web_application#cite_note-ntiered-4%23cite_note-ntiered-4http://en.wikipedia.org/wiki/Application_service_provider
  • 8/8/2019 Java Tecnlogies Web Application

    3/44

    Writing web applications

    There are many web application frameworks which facilitate rapid application development by allowing theprogrammer to define a high-level description of the program. In addition, there is potential for the development ofapplications onInternet operating systems, although currently there are not many viable platforms that fit this model.

    The use of web application frameworks can often reduce the number of errors in a program, both by making the code

    simpler, and by allowing one team to concentrate just on the framework. In applications which are exposed to constanthackingattempts on the Internet, security-related problems caused by errors in the program are a big issue. Frameworks

    may also promote the use of best practices such asGET after POST.

    Brief Introduction to the Web Application development

    Gone are the days of serving static HTML pages to the world. Now a days most website serves the dynamic pagesbased on the user and their inputs.

    This tutorial will take you through the process of developing a search engine. We will useJava Servlets

    to accomplish all this.

    This tutorial assumes that you are already familiar with Web concepts such as HTTP, browsers, andWeb Servers as

    well as the Java programming language.What is Web Application?

    First of all we learn what is Web Application? Any application that uses WebTechnologies including web browsers,

    web servers and Internet protocols is called Web Application.

    A web application can be divided into three different layers. Presentation layer which forms the first tier of theapplication, consists of web server and the web browser, which is responsible for assembling the data into presentable

    format. Application layer constitutes the second tier of the application and is consisting of server side program andscripts. Finally the third tier provides the programmable access to the databases. In an e-comm scenario when a user(first tier), send a request to the web server, web server process the request (Second and third tier), formats the resultand finally sends the formatted results (first tier) to the client.

    In this process server side scripts play a very important role of processing the users request and in the generation of

    dynamic pages, based on user and its input.

    In the next section we will describe the scripts used for generating the dynamic content.

    http://en.wikipedia.org/wiki/Web_application_frameworkhttp://en.wikipedia.org/wiki/Web_application_frameworkhttp://en.wikipedia.org/wiki/Web_application_frameworkhttp://en.wikipedia.org/wiki/Internet_operating_systemhttp://en.wikipedia.org/wiki/Internet_operating_systemhttp://en.wikipedia.org/wiki/Hacker_(computing)#Hacker:_Intruder_and_criminalhttp://en.wikipedia.org/wiki/Hacker_(computing)#Hacker:_Intruder_and_criminalhttp://en.wikipedia.org/wiki/Post/Redirect/Gethttp://en.wikipedia.org/wiki/Post/Redirect/Gethttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://en.wikipedia.org/wiki/Web_application_frameworkhttp://en.wikipedia.org/wiki/Internet_operating_systemhttp://en.wikipedia.org/wiki/Hacker_(computing)#Hacker:_Intruder_and_criminalhttp://en.wikipedia.org/wiki/Post/Redirect/Gethttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtmlhttp://www.roseindia.net/sourcecode/searchengine/introduction.shtml
  • 8/8/2019 Java Tecnlogies Web Application

    4/44

    Techniques used for Generating Dynamic Content

    Common Gateway Interface (CGI)

    For any web application high performance and timely delivery are key ingredients to competitive success.

    Earlier CGI was developed to provide the server-side capability to web application. Although CGI played a major role

    in the explosion of Internet, it's performance, scalability and usability issues make it less than the optimal solution. CGIruns in a separate process separated from the web server and it requires more hardware and software resources. CGI

    programs are slow because for each a new call is to the CGI program, which subsequently runs in a separate process. Ifyour program needs to interact with Web Server, using CGI program you can't accomplish it as CGI's separate process

    can't interact with Web Server.Scripting Languages

    To solve all these problems several companies have developed server-side scripting languages. These scripts are

    popular and allowsdevelopersto develop web applications that generates dynamic pages. Microsoft has developed ASP

    (Active Server Pages) for IIS Server and Cold Fusion is product of Allaire. Web Server interprets these scripts when thepages are served. These scripting languages provide good performance but imposes the portability issues as they arelimited to particular group of products or operating system.

    Java Servlets

    Java Servletseliminated all these problems. The first truly platform independent web development technique, Java Servlets breaks

    down all traditional barriers giving you flexibility to run your Web Application on any Web Server.

    Built from the ground up using Sun's write once run anywhere technology, Java Servlets provide excellent frameworkto develop server-side application without sacrificing functionality or performance.

    With Java Servlets you can finally develop your web application that can run on any platform. Java Servlets have

    number of advantages over CGI and other API's. They are:

    1. Platform Independence

    This is very important feature of Servlets, which makes them portable across platforms and across different WebServers, because the Servlet API defines a standard interface between a Servlet and a Web Server.

    2. Persistent:Java Servlets are loaded once by a Web Server when it receives a request from the client and serving the

    subsequent request is just a matter of creating new thread. Servlets can maintain system resources (e.g..database connectivity etc.) between requests, thus making it easy to share resources like database connectivity.

    3. Familiarity:Servlets are written in Java Language, so anyone having some programming knowledge in Java can learnServlets easily. This saves saves the valuable time of learning a new programming language.

    In the next section we learn about JDBC and see how to use JDBC to connect our search engine to database.

    http://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/index.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtmlhttp://www.roseindia.net/sourcecode/searchengine/001.shtml
  • 8/8/2019 Java Tecnlogies Web Application

    5/44

    Introduction to the JDBC

    Introduction

    This article introduce you with JDBC and shows you how to our search engine with database.

    What is JDBC?

    Java Database Connectivity or JDBC for short is set of Java API's that enables the developers to createplatform and database independent applications in java. The biggest advantage of programming in Java isits platform independence. An application written to access the MS Access database on Win 95/Win NTplatform can work on Linux againstOracle database, only by changing the name of driver, provided none ofthe database calls it makes are vendor specific.

    What are JDBC Drivers?

    JDBC Drivers are set of classes that enables the Java application to communicate with databases. Java.sqlthat ships with JDK contains various classes for using relational databases. But these classes do not provideany implementation, only the behaviors are defined. The actual implementations are done in third-partydrivers. Third party vendors implements the java.sql.Driver interface in their database driver. A list ofcurrently available JDBC drivers can be found athttp://java.sun.com/products/jdbc/jdbc.drivers.html

    JDBC Drivers Types

    Sun has defined four JDBC driver types. These are:

    1. Type 1: JDBC-ODBC Bridge Driver The first type of JDBC driver is JDBC-ODBC Bridge which provide JDBC access to any ODBCcomplaint databases through ODBC drivers. Sun's JDBC-ODBC bridge is example of type 1 driver.

    2. Type 2: Native -API Partly - Java Driver Type 2 drivers are developed using native code libraries, which were originally designed foraccessing the database through C/C++. Here a thin code of Java wrap around the native code andconverts JDBC commands to DBMS-specific native calls.

    3. Type 3: JDBC-Net Pure Java Driver Type 3 drivers are a three-tier solutions. This type of driver communicates to a middlewarecomponent which in turn connects to database and provide database connectivity.

    4. Type 4: Native-Protocol Pure Java Driver Type 4 drivers are entirely written in Java that communicate directly with vendor's databasethrough socket connection. Here no translation or middleware layer, are required which improvesperformance tremendously.

    Links to JDBC Drivers Site

    1. MERANT DataDirect provides JDBC driver technology through n-tier, server-based dataconnectivity and high-performance, DBMS-independent JDBC middleware.

    2. MM MySQL JDBC DRIVERS - 100% pure java driver for MySQL and is distributed under the GNULGPL.

    http://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://java.sun.com/products/jdbc/jdbc.drivers.htmlhttp://java.sun.com/products/jdbc/jdbc.drivers.htmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.ddjava.com/http://www.worldserver.com/mm.mysqlhttp://www.gnu.org/copyleft/gpl.htmlhttp://www.gnu.org/copyleft/gpl.htmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://java.sun.com/products/jdbc/jdbc.drivers.htmlhttp://www.roseindia.net/sourcecode/searchengine/002.shtmlhttp://www.ddjava.com/http://www.worldserver.com/mm.mysqlhttp://www.gnu.org/copyleft/gpl.htmlhttp://www.gnu.org/copyleft/gpl.html
  • 8/8/2019 Java Tecnlogies Web Application

    6/44

    3. The mSQL JDBC Driver-A pure-java JDBC driver for mSQL was created and is being maintainedby George Reese from The Center for Imaginary Environments.

    Connecting to the Database

    JDBC Driver In our search engine we are using MySQL databaseserver and MM.MySQL Driver for connecting our application tothe database. MM.MySQL Driver is available at http://www.worldserver.com/mm/mysql. As stated earlier

    MM.MySQL Driver is 100% pureJavaDriver for MySQL and is distributed under the GNUGLP.Developerscan usethis driver to make connections to MySQL server from both Java Applications and Applets. MM.MySQL Driver

    provide all the JDBC features. It automatically re-connect if connection is failed. It also provide Unicode support andsupport for varied character encoding.

    Connecting to the Database All the classes and interfaces of JDBC API are defined in java.sql package, so it is necessary to import java.sql.*

    package in our application.

    In this search engine our application communicate with database using JDBC and for making connection we areusing MM.MySQL JDBC Driver.

    First of all we obtain a Connection object that represents the network connection to the database. Driver Managerplays very important role of establishing connection. Class.forName("org.git.mm.mysql.Driver").newInstance() tells theDriver Manager to use MM.MySQL JDBC Driver. To obtain a connection to the Database getConnection() method of

    DriverManager class is used, which provides database connectivity to our search engine.

    import java.io.*;import java.util.Enumeration;import javax.servlet.*;import javax.servlet.http.*;

    import java.sql.*;import java.net.*;import java.util.*;

    public class search extends HttpServlet{

    //Connection object

    Connection theConnection;

    private String dbURL = "jdbc:mysql://10.0.0.1/javadevelopers?user=username&password=password";

    //private String servletURL="/servlet";

    private String servletURL="http://www.webappcabaret.com/javadevelopers";

    //private String image="/images/open.gif";

    private String image="http://www.roseindia.net/images/open.gif";

    public void init() throws ServletException{makeConnection();

    http://www.imaginary.com/http://www.imaginary.com/http://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.worldserver.com/mm/mysqlhttp://www.worldserver.com/mm/mysqlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.imaginary.com/http://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.worldserver.com/mm/mysqlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtmlhttp://www.roseindia.net/sourcecode/searchengine/003.shtml
  • 8/8/2019 Java Tecnlogies Web Application

    7/44

    }

    public void makeConnection(){

    //System.out.println("Opening db connection");

    try{

    Class.forName("org.gjt.mm.mysql.Driver").newInstance();theConnection = DriverManager.getConnection(dbURL);}catch (Exception e)

    {

    // System.out.println(e.getMessage());

    }

    // System.out.println("Connected to the database");

    }

    public void destory(){try{theConnection.close();

    }catch(Exception e){}

    }

    The close() method of Connection object closes the database connection.

    Web application tools

    20 tools for web application development

    One of the main reasons we started the One Month App is because people always seem to be interested in ourdevelopment process. One of the aspects of our development process is naturally the software and tools we use. The

    following is a list of the tools that we have used on this project and others, covering our full technology stack thatincludes desktop, hosted and server applications. We would be very interested to hear about any tools that you use inyour development process as well.

  • 8/8/2019 Java Tecnlogies Web Application

    8/44

    Ruby On Rails

    Rails is an open-source web application framework that is geared towards developerhappiness and sustainable productivity. This is currently our preferred framework and we have been using it for the

    past couple of years.

    Textmate

    Textmate is a text editor for Mac OS X. I found this editor a few years ago. Soon after that, Istarted seeing it used in a lot of screencasts that showcased various web development technologies. It appears like asimple editor, but it packs a lot of useful features under the hood.

    Skedit

    Skedit is another text editor for Mac OS X. We'd argue that Skedit is more designer friendly thanTextmate because some of it's default features sets such as special characters helpers and remote file capability. Skeditmakes writing clean markup a breeze for a web designer.

    Adobe Creative Suite

    A standard suite of software for any designer, we use Adobe Creative Suite for everything fromdesign mockups to slicing up graphics for the web.

    SnapNDrag

    A very simple piece of software for Mac OS X that allows you to take screen captures and simply dragthem from the software to another piece of software (such as Adobe Photoshop). This is great when you are consideringa UI change and you want to take a quick screenshot, pull it into Photoshop, and make a quick mock-up.

    http://rubyonrails.org/http://macromates.com/http://www.skti.org/skEdit.phphttp://www.adobe.com/products/creativesuitehttp://www.yellowmug.com/snapndraghttp://rubyonrails.org/http://macromates.com/http://www.skti.org/skEdit.phphttp://www.adobe.com/products/creativesuitehttp://www.yellowmug.com/snapndrag
  • 8/8/2019 Java Tecnlogies Web Application

    9/44

    Parallels

    Parallels is an essential tool for allowing cross platform/browser development. We use this as we aretesting our web applications in various web browsers and platforms.

    Firebug

    Firebug is a plug-in for Firefox that has many web development tools. The main use that I have for it is theinspect feature. This allows me to inspect the HTML at any time including after AJAX calls have taken place.

    Basecamp

    We use Basecamp to communicate and collaborate on all of our projects. It allows us to set up a schedulewith milestones and keep our messages and to-dos all in one spot.

    Lighthouse

    Lighthouse was developed by our friends at Active Reload. It's areasonably priced web based hosted tool for dealing with bug/issue tracking in software projects.

    Subversion

    Subversion is an open-source revision control system. I'm not really sure how we developed websites withoutusing subversion in the past. What I do know is that I do not want to go back. Not only does subversion keep track ofour revisions and protects us while multiple people are working on the same things, but it is also the reason that I

    hardly ever open up an FTP client. SorryTransmit, I still love you.

    Warehouse

    Warehouse was also developed by Active Reload. It is a web based tool that lets you

    browse through your subversion repositories. Unlike Lighthouse, you can install this software on a server of yourchoice.

    Terminal

    Terminal is my second most used application. I use it while working in my local environment as well asinterfacing with our servers. I have always liked Linux over Windows, but I felt that some of the user experience was a

    http://www.parallels.com/https://addons.mozilla.org/en-US/firefox/addon/1843http://www.basecamphq.com/http://lighthouseapp.com/http://activereload.net/http://activereload.net/http://activereload.net/http://subversion.tigris.org/http://www.panic.com/transmithttp://www.panic.com/transmithttp://www.panic.com/transmithttp://warehouseapp.com/http://activereload.net/http://activereload.net/http://activereload.net/http://en.wikipedia.org/wiki/Terminal_(application)http://www.parallels.com/https://addons.mozilla.org/en-US/firefox/addon/1843http://www.basecamphq.com/http://lighthouseapp.com/http://activereload.net/http://subversion.tigris.org/http://www.panic.com/transmithttp://warehouseapp.com/http://activereload.net/http://en.wikipedia.org/wiki/Terminal_(application)
  • 8/8/2019 Java Tecnlogies Web Application

    10/44

    bit lacking. When OSX came around with its BSD foundation a lot of us web developers started making the switch. It

    has great user experience, but you can open up the terminal and feel at home.

    Incubator

    I found this great piece of software about 3 years ago when it was known as pyramid. We use it for all sortsof various tasks that require organizing thoughts.

    SQLEditor

    I have been lightly searching for a simple Entity Relationship Diagram (ERD) tool that was native toOSX for the past few years. This is a tool that I found when I started this project. It certainly fits what I am looking for.

    MySQL

    MySQL is an open-source database that we use for most of our web applications. Another great

    package that we occasionally use is PostgreSQL.

    MySQL Query Browser

    MySQL Query Browser is a GUI application to help you take a quick glance at your queries. With featuresthat allow you to save and bookmark queries, as well as built-in documentation on the available features of MySQL,

    this tool makes developing and working with schemas an easy process.

    Linux

    Linux has been my preferred server operating system for nearly a decade or as long as I've been developingweb applications. All of the tools that I use are at home on this platform.

    Mongrel & Mongrel Cluster

    Mongrel is a fast HTTP server for Ruby applications. Mongrel Clusteris a GemPluginthat wraps the mongrel HTTP

    server and simplifies the deployment of web applications using a cluster of Mongrel servers. Mongrel Cluster willconveniently configure and control several Mongrel servers, or groups of Mongrel servers, which are then load

    balanced using a reverse proxy solution.

    http://www.mindcad.com/http://www.malcolmhardie.com/sqleditorhttp://www.mysql.com/http://postgresql.org/http://www.mysql.com/products/tools/query-browserhttp://www.linux.org/http://mongrel.rubyforge.org/http://rubyforge.org/projects/railsmachine/http://rubyforge.org/projects/railsmachine/http://mongrel.rubyforge.org/gem_plugin_rdochttp://mongrel.rubyforge.org/gem_plugin_rdochttp://mongrel.rubyforge.org/gem_plugin_rdochttp://www.mindcad.com/http://www.malcolmhardie.com/sqleditorhttp://www.mysql.com/http://postgresql.org/http://www.mysql.com/products/tools/query-browserhttp://www.linux.org/http://mongrel.rubyforge.org/http://rubyforge.org/projects/railsmachine/http://mongrel.rubyforge.org/gem_plugin_rdoc
  • 8/8/2019 Java Tecnlogies Web Application

    11/44

    Nginx

    Nginx is a lightweight HTTP server that we use as a reverse proxy for our Mongrel Cluster. It

    also serves up our static and cached files.

    Monit

    Monit is a utility for managing and monitoring, processes, files, directories and devices on a UNIX system. Monitconducts automatic maintenance and repair and can execute meaningful causal actions in error situations. We mostly

    use monit to keep track of our Mongrel processes. If one fails or starts using too much ram, it will automatically restartit.

    Web appilication development using java technologies:-

    Article

    Developing Web Applications With JavaServer Pages 2.0

    http://nginx.net/http://www.tildeslash.com/monithttp://nginx.net/http://www.tildeslash.com/monit
  • 8/8/2019 Java Tecnlogies Web Application

    12/44

    JavaServer Pages (JSP) technology, which abstracts servlets to a higher level, is an open, freely-available

    specification developed by the Java Community Process (JCP) for generating dynamic content, and a keycomponent of the Java 2 Enterprise Edition (J2EE) specification. Many commercially available application servers(such as BEA WebLogic, IBM WebSphere, Live JRun, and Orion) support JSP technology.

    JSP technology is being used everywhere on the Web including airline reservation systems, banking systems, and

    shopping. The new release, Version 2.0, is an upgrade to JSP 1.2 with several interesting new features. Theobjective of JSP 2.0 is to make the task of developing dynamic Web pages easier than ever without having to learn

    the Java programming language.

    This article:

    Provides a fast track code intensive tutorial to get started with JSP 2.0

    Describes the new features in JSP 2.0

    Offers a flavor of the effort involved in developing applications using JSP 2.0

    Provides sample code that you can adapt for your own applications

    If you are new to JSP, it might be a good idea to start directly with JSP 2.0. However, if you wish to learn aboutJSP 1.2 you may want to start with thisJSP tutorial.

    JSP 2.0

    JSP 2.0 is an upgrade to JSP 1.2 with several new interesting features that make the lives of Web application

    designers and developers easier. The objective of JSP 2.0 is to make JSP easier to use than ever, and moreimportantly to be used without having to learn the Java programming language itself. It simplifies the Tag APIs byadding a new extension mechanism called SimpleTag.

    In addition to several other improvements, the new key features that have been introduced in JSP 2.0 are:

    1. A simple expression language (EL), which can used to easily access data from JSP pages. The expressionlanguage simplifies writing scriptless JSP-based applications without using Java scriptlets or Javaexpressions.

    2. New syntax for defining reusable custom actions using JSP technology directly. The syntax is deliveredinto .tag and .tagx files which can be written by developers and page authors.3. The XML syntax has been improved substantially. The new standard filename extensions (.tagx for tagfiles and .jspx for JSP files) have been added.

    In this article I concentrate on the Expression Language, the simplified Tag API, and tag files. I believe existingJSP developers will find these key features to be very interesting and useful.

    Why the Jump from 1.2 to 2.0?

    The version number was originally listed as 1.3 in the Java Specification Request (JSR 152). However, given thatthe new features would have a deep impact on the development model of JSP applications as you will see later, the

    Expert Group felt it was necessary to upgrade the major version number to 2.0 since this would reflect the impactmore appropriately. Also, the new version number will help draw the attention of developers to these new

    interesting features. The good news is that all valid JSP 1.2 pages are also valid JSP 2.0 pages.

    Getting Started with JSP 2.0

    In order to get started with JSP 2.0, you need a JSP container that supports the JSP 2.0 specification and the JavaServlet 2.4 specification. Luckily, Jakarta Tomcat 5.0 (Alpha release) supports the new JSP 2.0 and Servlet 2.4

    specifications. Download and install Tomcat 5.0.

    http://java.sun.com/developer/technicalArticles/xml/WebAppDev/http://java.sun.com/developer/technicalArticles/xml/WebAppDev/http://java.sun.com/developer/technicalArticles/xml/WebAppDev/http://jakarta.apache.org/builds/jakarta-tomcat/release/v5.0.2-alpha/http://jakarta.apache.org/builds/jakarta-tomcat/release/v5.0.2-alpha/http://java.sun.com/developer/technicalArticles/xml/WebAppDev/http://jakarta.apache.org/builds/jakarta-tomcat/release/v5.0.2-alpha/
  • 8/8/2019 Java Tecnlogies Web Application

    13/44

    The JSP Expression Language

    Information to be passed to JSP pages is communicated using JSP scoped attributes and request parameters. Anexpression language (EL), which is designed specifically for page authors, promotes JSP scoped attributes as the

    standard way to communicate information from business logic to JSP pages. Note, however, that while the EL is a

    key aspect of the JSP, it is not a general purpose programming language. Rather, it is simply a data accesslanguage, which makes it possible to easily access (and manipulate) application data without having to usescriptlets or request-time expression values.

    Prior to JSP 2.0, a page author had to use the expression to access the value of a system, as in the

    following example:

    or the value of a custom JavaBeans component:

    An expression language allows a page author to access an object using a simplified syntax. For example, to accessa simple variable, you can use something like:

    And to access a nested JavaBeans property, you would use something like:

    ${aCustomer.address.country}

    But, you might ask, isn't this JavaScript syntax? You are absolutely right! If you've worked with JavaScript, youwill feel right at home, because the EL borrows the JavaScript syntax for accessing structured data.

    Note: The Expression Language was originally developed as part of the JavaServer Pages Standard Tag Library

    (JSTL) 1.0, which is a standard tag library that provides support for common, structural tasks, such as iteration andconditionals, processing XML documents, internationalization, and database access using the Structured QueryLanguage (SQL). The JSTL specification is being developed by the JSR 52 expert group. For a tutorial on JSTL,

    please see Faster Development with JSTL.

    Accessing Application Data

    You can access application data either as a property of an object, using the dot (.) operator, or a named array

    element using the bracket ['name'] operator.

    The expression ${data} represents the scoped variable named data. You can retrieve properties from

    collections using either the dot (.) or bracket ([]) operator:

    The dot (.) operator is used to retrieve a named property. For example, the expression $

    {customer.name} indicates the name property of the customer scoped variable.

    The bracket operator ([]) can be used to retrieve a named property, as in ${customer["name"]}.

    The bracket operator can also be used as ${customers[0]} to refer to the first item in the customers

    collection.

    The expression language unifies the treatment of dot (.) and bracket ([]) operators. Therefore, $

    {customer.name} is equivalent to ${customer["name"]}. As you can see, all EL expressions must be

    enclosed between ${ and }.

    http://java.sun.com/developer/technicalArticles/javaserverpages/fasterhttp://java.sun.com/developer/technicalArticles/javaserverpages/fasterhttp://java.sun.com/developer/technicalArticles/javaserverpages/faster
  • 8/8/2019 Java Tecnlogies Web Application

    14/44

    The EL evaluates an identifier by looking up its value as an attribute using

    PageContext.findAttribute(String). If the attribute is not found, null is returned.

    Operators

    The EL supports arithmetic, relational, and logical operators to handle the most common data manipulations. Inaddition, a special operator for testing if an object is empty is provided. The operators are shown in Table 1. You

    can use the empty operator to determine whether a collection or a string is empty or null. For example, $

    {empty param.name} will be true only if the request parameter named param is not present. The empty

    operator can be combined with the ! operator, as in the expression ${!empty param.name}, which evaluates

    to true if the request parameter named param is present.

    Table 1: Expression language operators

    Operator Description

    + Addition

    - Subtraction

    * Multiplication

    / ordiv Division

    % ormod Modulus (Remainder)

    == or= Equality

    != or!= Inequality

    < orlt Less than

    > orgt Greater than

    = orge Greater than or equal to

    && orand Logical AND

    || oror Logical OR

    ! ornot Boolean complement

    empty Check for empty value

    a ? b : c Conditional operator

    Implicit Objects

    In addition to operators, the EL defines implicit objects to support access to application data that is of interest to

    page authors. The implicit objects defined by the EL are shown in Table 2. An example of how to use some ofthese implicit objects is provided later.

    Table 2: Implicit objects provided by the expression language

    Implicit Object Content

    applicationScope A collection of scoped variables from applications scope

    cookie A collection of all cookies

  • 8/8/2019 Java Tecnlogies Web Application

    15/44

    header HTTP request headers as strings

    headerValues HTTP request headers as collections of strings

    initParam A collection of all application parameter names

    pageContextThe javax.servlet.jsp.PageContext object for

    the current page

    pageScope A collection of all page scope objects

    param A collection of all request parameters as strings

    paramValues All request parameters as collections of strings

    requestScope A collection of all request scope objects

    sessionScope A collection of all session scope objects

    EL Example

    As you can tell, web page authors can use the Expression Language without having to learn Java. Code Sample 1

    shows some EL expressions as well as the use of explicit objects.

    Code Sample 1: ex1.jsp

    Expression Language Examples

    JSP Expression Language Examples

    The following table illustrates some EL expressions and implicit objects:

    Expression

    Value

    \${2 + 5}

    ${2 + 5}

    \${4/5}

    ${4/5}

    \${5 div 6}

    ${5 div 6}

    \${5 mod 7}

    ${5 mod 7}

    \${2 < 3}

    ${2 < 3}

  • 8/8/2019 Java Tecnlogies Web Application

    16/44

    \${2 gt 3}

    ${2 gt 3}

    \${3.1 le 3.2}${3.1 le 3.2}

    \${(5 > 3) ? 5 : 3}

    ${(5 > 3) ? 5 : 3}

    \${header["host"]}

    ${header["host"]}

    \${header["user-agent"]}

    ${header["user-agent"]}

    In order to run this, do the following. Here I assume that Tomcat 5.0 is installed at c:\Tomcat5.0

    1. Change directory to c:\Tomcat5.0\webapps\jsp-examples2. Create a directory and name it whatever you like, let's say jsp2-tutorial3. Change directory to jsp2-tutorial

    4. Copy the ex1.jsp from this article and save it there5. Start the Tomcat 5 server by going to Start->Programs->Apache Tomcat 5.0->StartTomcat

    6. In your Web browser, enter http://localhost:8080/jsp-examples/jsp2-tutorial/ex1.jsp

    You should something similar to Figure 1. It is that simple to use the Expression Language!

  • 8/8/2019 Java Tecnlogies Web Application

    17/44

    Figure 1: JSP Expression Language and Implicit Objects

    Note: In this article, all JSP pages will be saved underc:\Tomcat5.0\webapps\jsp-examples\jsp2-

    tutorial.

    Fill-Out-Form Example

    The implicit object, $param[var] can be used to read values from a fill-out form. Code Sample 2 shows a

    simple example of a fill-out form that prompts the user to enter a name.

    Code Sample 2: form.jsp

    Form Content

    Fill-out-form

    Name =

    The Name is: ${param.name}

  • 8/8/2019 Java Tecnlogies Web Application

    18/44

    In this example, when the user enters a name and clicks the "Submit Name" button, the name entered will be

    displayed on the same page next to "The Name is: " as shown in Figure 2.

    Again, in order to run this example, simply copy form.jsp to c:\Tomcat5.0\webapps\jsp-

    examples\jsp2-tutorial and request that page from a Web browser.

    Figure 2: Handling forms

    Developing and Using Functions

    The expression language allows you to define functions that can be invoked in an expression. Functions must be

    programmed as a public static method in a public class. Once the function is developed, its signature is

    mapped in a Tag Library Descriptor (TLD).

    To illustrate the use of functions, I use a simple example to add two numbers. First we write the Java code for themethod to add two numbers. Code Sample 3 shows a static method that accepts two Strings, parses them to

    integers, and returns their sum.

    Code Sample 3: Compute.java

    package jsp2.examples.el;

    import java.util.*;

    public class Compute {

    public static int add(String x, String y) {

    int a = 0;

    int b = 0;

    try {

    a = Integer.parseInt(x);

    b = Integer.parseInt(y);

    }catch(Exception e) {}

    return a + b;

    }

    }

    Once this is successfully compiled using javac, the next step is to map the function's signature in the tag library.

    Code Sample 4 shows how to map the add function to the class containing the implementation of the function and

    the signature of the function. I will tell you where to add this later.

    Code Sample 4: Function Descriptor

  • 8/8/2019 Java Tecnlogies Web Application

    19/44

    add x and y

    add

    jsp2.examples.el.Compute

    int

    add(java.lang.String,java.lang.String)

    Now, we can write the JSP page that uses the function. Code Sample 5 shows a form with two fields. The userenters two numbers and when the "Add Numbers" button is clicked, the function is called to add the numbers. The

    result is displayed on the same page.

    Code Sample 5: math.jsp

  • 8/8/2019 Java Tecnlogies Web Application

    20/44

    If all goes well, you should see something similar to Figure 3.

    Figure 3: Using Functions

    Tag Handlers

    The APIs for classic tag handlers in JSP 1.2 is complicated by the allowance of scriptlets in the body of tags. With

    the expression language, however, it is now feasible to develop scriptless JSP pages. To this end, JSP 2.0 hasintroduced a new type of tag extension called a Simple Tag Extension that can be used in one of two ways:

    1. Java developers: by defining a class that implements thejavax.servlet.jsp.tagext.SimpleTag interface.

    2. Page authors who do not know Java: by using tag files.

    Here is an example of the first approach. Code Sample 6 shows a simple tag handler that prints This is my

    first tag!.

    Code Sample 6: HelloTag.java

    package jsp2.examples.simpletag;

    import javax.servlet.jsp.JspException;

    import javax.servlet.jsp.tagext.SimpleTagSupport;

    import java.io.IOException;

    /**

    * SimpleTag handler that prints "This is my first tag!"

    */

    public class HelloTag extends SimpleTagSupport {

    public void doTag() throws JspException, IOException {

    getJspContext().getOut().write("This is my first tag!");

    }

    }

    Once this is successfully compiled, the next step is to define a tag descriptor in a TLD. Code Sample 7 shows asample tag descriptor:

    Code Sample 7: Tag Descriptor

  • 8/8/2019 Java Tecnlogies Web Application

    21/44

    Prints this is my first tag

    hello

    jsp2.examples.simpletag.HelloTag

    empty

    And finally, Code Sample 8 shows a JSP page that uses the tag I have just developed.

    Code Sample 8: helloworld.jsp

    Simple Tag Handler

    Simple Tag Handler

    My first tag prints:

    To run this example:

    1. Copy HelloTag.java and save it under C:\Tomcat5.0\webapps\jsp-examples\WEB-INF\classes\jsp2\examples\simpletag

    2. Compile the HelloTag.java using javac3. Append the tag description shown in Code Sample 7 to the end of the file:C:\Tomcat5.0\webapps\jsp-examples\WEB-INF\jsp2\jsp2-example-taglib.tld,

    before

    4. Copy helloworld.jsp and save it at: c:\Tomcat5.0\webapps\jsp-examples\jsp2-tutorial

    5. Request helloworld.jsp from a web browser

    If all goes well you should see something similar to Figure 4.

    Figure 4: Simple Tag Handler Example

    Tag File

  • 8/8/2019 Java Tecnlogies Web Application

    22/44

    The other way of using the Simple Tag Extension is through the use of tag files. A tag file is a source file that

    provides a way for a page author to abstract a segment of JSP code and make it reusable through a custom action.In other words, tag files allow JSP page authors to create reusable tag libraries using JSP syntax. The required file

    extension for a tag file is .tag.

    To demonstrate how easy this is, consider the tag file in Code Sample 9. That is right, this is a tag file!

    Code Sample 9: greetings.tag

    Hello there. How are you doing?

    Once a tag file has been defined, you can write a JSP page that uses this custom action. As an example, considerthe JSP page in Code Sample 10.

    Code Sample 10: chat.jsp

    JSP 2.0 Examples - Hello World Using a Tag File

    Tag File Example

    The output of my first tag file is:

    To run this example:

    1. Copy the tag file, greetings.tag, and save it under c:\Tomcat5.0\webapps\jsp-examples\WEB-INF\tags

    2. Copy the JSP page, chat.jsp, and save it at c:\Tomcat5.0\webapps\jsp-examples\jsp2-tutorial

    3. Request the chat.jsp file from a Web browser

    If all goes well, you should see something similar to Figure 5.

    Figure 5: Simple Tag File Example

    Note: What is important to notice here is that I did not need to write a TLD for the greetings tag. I just created thetag file in a special directory, and imported it using the taglib directive, and used it!

    Another Tag File Example

  • 8/8/2019 Java Tecnlogies Web Application

    23/44

    Tag files can be used as a template. Consider the tag file, display.tag, shown in Code Sample 11. This

    example is adapted from the panel example that comes with Tomcat 5.0. The attribute directive is analogous

    to the element in the TLD; it allows for the declaration of custom action attributes.

    Code Sample 11: display.tag

    ${title}

    Code Sample 12 shows a simple JSP page that uses the display tag.

    Code Sample 12: newsportal.jsp

    Another Tag File Example

    News Portal: Another Tag File Example

    Last French Concorde Arrives in NY

    Another Travel Headline

    Yet Another Travel Headline

    Java for in-flight entertainment

    Another Technology Headline
    Another Technology Headline

    American Football

    NBA

    Soccer

  • 8/8/2019 Java Tecnlogies Web Application

    24/44

    To run this example:

    1. Copy the file display.tag and save it underc:\Tomcat5.0\webapps\jsp-examples\WEB-INF\tag

    2. Copy the file newsportal.jsp and save it under c:\Tomcat5.0\webapps\jsp-examples\jsp2-tutorial

    3. Request the newsportal.jsp from a Web browser

    Now, you should see something similar to Figure 6.

    Figure 6: Using Tag File as a Template

    Conclusion

    JSP 2.0 makes is easier than ever to rapidly develop and easily maintain dynamic Web pages. Despite the fact theword "Java" appears in JavaServer Pages, with JSP 2.0 page authors can develop innovative dynamic Web pages

    without having to learn the Java programming language. The examples shown throughout the article demonstratehow easy it is to get started using the new features in JSP 2.0 to develop dynamic Web pages.

    Develop web application with netbeans ,seam and Glassfish

    In this two part series I will try to show you how easily you can build applications using NetBeans 5.5 based on seam ,facelets , jsf and new EJB 3 standard.

    I will not discuss any of framework in details as you can find detailed information about each of them in theirhomepage and some other articles.I want just show , How you can use NetBeans with some leading frameworks to build your web based applications. I

  • 8/8/2019 Java Tecnlogies Web Application

    25/44

    will not discuss NetBeans specific tasks in details .

    I will more focus on leveraging this stuff together using NetBeans IDE.

    What you will need to follow this series :

    NetBeans enterprise edition 5.5 , you will need Glassfish or JBoss to continue with this series.

    check and make sure that your NetBeans has application server bundled otherwise get a copy ofglassfish from its website.

    seam 1.0.1 GA or newer.

    seam distribution contain Facelets too , but i strongly suggest you get Facelets distribution separately and take a look atits samples and very good documentation. indeed both Facelets and seam has very good documentation.

    In this entry I will introduce each of this frameworks in very brief to make the series stand alone , and i will show youhow to setup the development environment and we will go with first part which is developing seam layer codes.

    JBoss seam is created to leverage maximum possible feature of Java EE 5 standards like JSF and EJB3.seam , seamlessly integrate EJB3 as a backend with JSF as presentation , meanwhile provide management of longrunning process

    by using JBPM . and give you ability to focus on your business logic rather than silly data providing stuff. By

    leveraging Facelets helps you to do even more with seam and JSF.

    To name its features I can say:

    Lesser XML, More Annotation. (please do not blame me for naming annotation and XML in one line:-))

    it let you go with your business logic rather thinking and resolving some common issue like userconversation state.

    seam has a more flexible context model , it has 8 context , by means of this context you canmanage your application more effective. for example a business process live in business processcontext .

    Accessing each component in entire seam context with one unique name.

    Managing workplaces and conversations .

    It easily will let you develop Portlet by providing a Portlet context . we will discuss this item in latterparts

    With many more features.

    But about JSF , JSF is a web framework , it is Standard and Developed under JSR 127.Some of JSF features are as follow:

    User interface framework

    Server-side UI components

    Event model , something like desktop applications event model , but very reduced.

    Component state

    Renderers , Render Kits , for example ADF faces has a telnet render which make it possible to

    render a ADF faces application for a telnet client. Validation

    Type conversion

    Internationalization

    about Facelets , we will discuss more in next articles , but for now you should know that Facelets bring some viewrelated enhancement and features to JSF community .To name some of features :

  • 8/8/2019 Java Tecnlogies Web Application

    26/44

    Facelets make it possible to develop your entire web pages using your favorite page designer likeDream weaver or Microsoft FrontPage. to achieve this feature it introduce a new attribute, jsfc ,thatmake it possible to change each html element to a JSF equal component. it is similar to Tapestry's jwcid attribute. So you can use all binding and event handling stuff of JSF and availability and

    ease of use of html WYSIWYG.

    Facelets provide a template-ing features like Velocity's for JSF . it allows you to test JSF views outof container.

    Some decoration features like what tile bring to struts community and SiteMesh ,generally, to alljava based web application.

    lets start the job of creating simplest sample ;) .

    I assume that you download seam and extract it in seam_home Also your NetBeans 5.5 is running and an application

    server capable of containing ejb3 (Glassfish) is configured with your IDE.

    for sake of simplicity we make one Library in our NetBeans IDE to make our job easier. as you know each library

    could contain some jar files, etc...

    Create a library name it seam and add the following jar files to it , the first

    seam_home\jboss-seam.jarseam_home\jboss-seam-ui.jarseam_home\hibernate-all.jarseam_home\thirdparty-all.jar

    add seam library to Registeration-EJBModule and Registeration-WebModule

    Switch to runtime view (CTRL+5).Extend database node , if you have no database created in your embedded derbythen create a database and create a table with following characteristics

    Table Name: usersFields :

    usernamevarcahr(255) ,

    primary key

    passwordvarchar(255) , notnull

    namevarcahr(255) , notnull

    after you create this table , create a new enterprise application project by going to , file>new project>enterpriseapplication

    name it Registeration. make sure that you have selected the Java EE 5 as j2ee version.

    go to project view (CTRL+1) And select Registeration-ejbModule , right click on it and select CMP entity bean fromdatabase...

    Now you should be able to select the JDBC connection that you have made in above step and give it a package name.click next and select users table from left column and add it to right column.

    click finish.That's it , you have your CMP ready to go.

    what we need to add to the CMP bean class in addition to its created structure

    another constructor with all the CMP fields.

    some annotation for getters , to help us in validation

    final shape of users CMP will be like :

  • 8/8/2019 Java Tecnlogies Web Application

    27/44

    package cmps;

    import java.io.Serializable;

    import javax.persistence.Column;

    import javax.persistence.Entity;

    import javax.persistence.GeneratedValue;

    import javax.persistence.GenerationType;

    import javax.persistence.Id;import javax.persistence.Table;

    import org.hibernate.validator.Length;

    import org.hibernate.validator.NotNull;

    import org.jboss.seam.annotations.Name;

    import org.jboss.seam.annotations.Scope;

    /**

    *

    * @author Masoud Kalali

    */

    @Entity

    @Name("user")

    @Scope(org.jboss.seam.ScopeType.SESSION)

    @Table(name="users")

    public class Users implements Serializable{private static final long serialVersionUID = 1881413500711441951L;

    private String username;

    private String password;

    private String name;

    /** Creates a new instance of Users */

    public Users() {

    }

    public Users(String name, String password, String username)

    {

    this.name = name;

    this.password = password;this.username = username;

    }

    @Id

    @GeneratedValue(strategy = GenerationType.AUTO)

    @Column(name = "username", nullable = false)

    @Length(min=5, max=15)

    public String getUsername() {

    return this.username;

    }

    public void setUsername(String username) {

    this.username = username;

    }

    @Column(name = "password", nullable = false)

    @Length(min=5, max=15)

    public String getPassword() {

    return this.password;

    }

    public void setPassword(String password) {

    this.password = password;

    }

  • 8/8/2019 Java Tecnlogies Web Application

    28/44

    @Column(name = "name", nullable = false)

    @Length(min=5, max=15)

    public String getName() {

    return this.name;

    }

    public void setName(String name) {

    this.name = name;

    }

    }

    we are finished with our POJO EJB :-) , now lets go and handle web layer stuff , from now we are working with seamview layer and JSF , I will talk about Facelets later in other articles of this series.

    as I said in sample scenario we have just one action , so we can use a managed bean or plain java object or whateverthat is useable here as action listener or use a stateless session bean (using session bean is what JBoss offer) so we willuse a stateless session bean to implement our action listener , it will also helps you to see how an stateless session beanis implemented in java EE 5.

    so create a session bean by using , file > new > session bean , now you can select session bean type to be stateless , andchange the package name to be sbeans

    click finish , editor will open up and show you the stateless seasion bean class.

    change the class body , in a way that final class looks like :

    import cmps.Users;

    import java.util.List;

    import javax.ejb.Stateless;

    import javax.faces.application.FacesMessage;

    import javax.faces.context.FacesContext;

    import javax.persistence.EntityManager;

    import javax.persistence.PersistenceContext;

    import org.hibernate.validator.Valid;

    import org.jboss.seam.annotations.Factory;

    import org.jboss.seam.annotations.IfInvalid;

    import org.jboss.seam.annotations.In;import org.jboss.seam.annotations.Name;

    import org.jboss.seam.annotations.Outcome;

    import org.jboss.seam.annotations.datamodel.DataModel;

    import org.jboss.seam.core.FacesMessages;

    import org.jboss.seam.ejb.SeamInterceptor;

    @Stateless

    @Name("")

    public class ActionBean implements sbeans.ActionLocal

    {

    @IfInvalid(outcome=Outcome.REDISPLAY)

    public String ()

    {

    List existing = em.createQuery("select username from User where

    username=:username")

    .setParameter("username", user.getUsername())

    .getResultList();

    if (existing.size()==0)

    {

    em.persist(user);

    return "success";

    }

    else

    {

    FacesMessages.instance().add("User #{user.username} already exists");

  • 8/8/2019 Java Tecnlogies Web Application

    29/44

    return "success";

    }

    }

    }

    we will need to add same method signature to our session bean local interface , so add the method signature toActionLocalclass. it will looks like :package sbeans;

    /**

    * This is the business interface for Action enterprise bean.

    */

    public interface ActionLocal {

    public String ();

    }

    now we are finished with the action , you may ask what are those annotation stuff in the session bean , so I should askyou to take a look at seam reference or wait until next part of this series. I should say that it is a very same version of

    seam sample that is implemented again in NetBeans IDE.we are finished with EJBModule for now , lets take a look at what we will have in web module. first of all you need toadd JSF framework to web module to do this , right click on web module and select properties , go to frameworks nodeand add JSF framework to the project. In web module we just have 2 JSF pages , one to , one to show the that s/he ed .

    Create following JSF files ,

    register.jsp same as seam sample register.jsp , used for registering purpose

    registered.jsp same as seam sample registered.jsp , used for showing the user that he/she is ed

    we need to add some navigation case to our faces-config.xml , so extend web module note and under configuration filesopen the faces-config.xml we should add 4 navigation case to it , so right click inside the editor ,which show content of

    faces-config.xml, and select add navigation rule. a dialog will open , just fill the dialog as following table show

    Rule From View /register.jsp

    Now right click in the editor and add 4 new navigation case , these cases will handle navigating from one view toanother.

    From View From Outcome To view

    /register.jsp success registered.jsp

    lets code with the register.jsp , open the register.jsp in your NetBeans editor change the content to :

    New User

    Username

    Real Name

  • 8/8/2019 Java Tecnlogies Web Application

    30/44

    Password

    No we need to create the registered.jsp which show that our user is registered. open the file in your editorand change its content to looks like :

    Successfully ed New User

    Welcome, ,

    you are successfully ed as .

    Now we are almost finished with JSf files , there are some changes that we should make in web.xml and faces-config.xml.first open web.xml and add the following lines to it.make sure the you add them directly inside

    node.

    org.jboss.seam.core.init.jndiPattern

    java:comp/env/registration/#{ejbName}/local

    org.jboss.seam.servlet.SeamListener

    registration/RegisterActionBean/local

    Sessionsbeans.RegisterActionLocal

    < ejb-link>RegisterActionBean

    Now open faces-config.xml and add the following lines to it. org.jboss.seam.jsf.SeamPhaseListener

    That's it , you are finished creating your first seam sample in netbeans , lets execute the application and see

  • 8/8/2019 Java Tecnlogies Web Application

    31/44

    the result. press f6 and wait until your browser opens , navigate to http://localhost:8080/Registration-WebModule/faces/register.jspenter some information and then press register button.

    You can check whether it applied or not by switching to runtime view and checking your Users table data . you canfind complete explanation of jsp/java codes in Seam tutorial chapter 1 at :http://docs.jboss.com/seam/1.0.0.GA/reference/en/html/tutorial.html

    Getting Started with Java Web Development in Eclipse and Tomcat

    (Page 1 of 4 )

    This is the first part of a series of Java Web development tutorials. It is intended to warm you up by introducing twofundamental Java web components, JSP and Servlet, and helping you prepare your development and deployment

    environments for the next steps.

    After you finish this tutorial, you'll understand the basic concepts of the JSP and Servlet as

    web application building components and how they work behind the scenes. The relationshipbetween the JSP and Servlet, which puzzles many new Java web developers and is largelyignored by many tutorials, will also be revealed. Along with this information, you will also getfull-featured environments for production level web development platforms to take your webprogramming to the next level.

    I assume you have some experience with Java and understand such concepts as class,inheritance, package, classpath, etc. You should also have a good understanding ofwebservers , URLs, HTTP, and HTML.

    In future articles we are going to dig into JSP's and Servlet's advanced features, learndatabase-driven web development, experiment with some emerging technologies like XML,Struts, Hibernate, Spring Framework, and Ajax in the context of Java web development. In thefinal tutorial, we'll put them together, using all of those techniques to build a full-blownproduction level web application.

    Web Application Development with JSP and XML

    Part I: Fast Track JSP

    Date and Time

    This example contains traditional HTML and some Java code. The tag tag identifies the end of a scriptlet. When date.jsp is requested from a web browser, you see something similar to Figure 1. Figure 1: Requesting date.jsp

    Behind the ScenesWhen this page (date.jsp) is called, it will be compiled (by the JSP engine) into a java servlet. At this point the servlet is handled by the servlet engine just like any other servlet. The servlet engine then loads the

    servlet class (using a class loader) and executes it to create dynamic HTML to be sent to the browser, as shown in Figure 2. For this example, the servlet creates a Date object and writes it as a string to the out object, which is an

    output stream to the browser. Figure 2: Request/Response Flow when Calling a JSP The next time the page is requested, the JSP engine executes the already-loaded servlet unless the JSP page has changed, in which case it is automatically recompiled into a servlet and executed. Scripting ElementsIn the date.jsp example the full Date classname is used including the package name, which may become tedious. If you want to create an instance of Date

    simply by using: Date today = new Date(); without having to specify the full class path use the page directive asfollows: Sample 2 :date2.jsp

    http://localhost:8080/Registration-WebModule/faces/index.jsphttp://localhost:8080/Registration-WebModule/faces/index.jsphttp://localhost:8080/Registration-WebModule/faces/index.jsphttp://docs.jboss.com/seam/1.0.0.GA/reference/en/html/tutorial.htmlhttp://www.devarticles.com/#%23http://www.devarticles.com/#%23http://www.devarticles.com/#%23mailto:?subject=Sun%20Web%20Page:%20Web%20Application%20Development%20with%20JSP%20and%20XMLPart%20I:%20Fast%20Track%20JSP%C2%A0%C2%A0Print-friendly%20VersionPrint-friendly%20Version%C2%A0%20Articles%20IndexBy%20Qusay%20H.%20Mahmoud(June%202001)If%20you%20have%20had%20the%20opportunity%20to%20build%20web%20applications%20using%20technologies%20such%20as%20Common%20Gateway%20Interface%20(CGI)%20and%20servlets,%20you%20are%20accustomed%20to%20the%20idea%20of%20writing%20a%20program%20to%20generate%20the%20whole%20page%20(the%20static%20and%20the%20dynamic%20part)%20using%20that%20same%20program.%20If%20you%20are%20looking%20for%20a%20solution%20in%20which%20you%20can%20separate%20the%20two%20parts,%20look%20no%20further.%20JavaServer%20Pages%20(JSP)%20are%20here.%20JSP%20pages%20allow%20you%20to%20separate%20front-end%20presentation%20from%20business%20logic%20(middle%20and%20back-end%20tiers).%20It%20is%20a%20great%20Rapid%20Application%20Development%20(RAD)%20approach%20to%20Web%20applications.%20This%20series%20of%20articles%20provides%20a%20hands-on%20tutorial%20explaining%20how%20to%20develop%20modern%20Web%20applications%20for%20today%27s%20and%20tomorrow%27s%20market.%20This%20series%20begins%20with%20this%20article,%20which%20explains%20the%20concepts%20and%20benefits%20of%20JSP%20technology,%20and%20then%20shows%20you%20how%20to%20utilize%20this%20exciting%20technology,%20and%20how%20to%20create%20reusable%20components%20for%20handling%20forms.%20The%20Dynamic%20WebThe%20Web%20has%20evolved%20from%20a%20network-based%20hypermedia%20distributed%20information%20system%20offering%20static%20information%20to%20a%20marketplace%20for%20selling%20and%20buying%20goods%20and%20services.%20The%20increasingly%20sophisticated%20applications%20to%20enable%20this%20marketplace%20require%20a%20technology%20for%20presenting%20dynamic%20information.%20First%20generation%20solutions%20included%20CGI,%20which%20is%20a%20mechanism%20for%20running%20external%20programs%20through%20a%20web%20server.%20The%20problem%20with%20CGI%20scripts%20is%20scalability;%20a%20new%20process%20is%20created%20for%20every%20request.%20Second%20generation%20solutions%20included%20web%20server%20vendors%20providing%20plug-ins%20and%20APIs%20for%20their%20servers.%20The%20problem%20is%20that%20their%20solutions%20were%20specific%20to%20their%20server%20products.%20For%20example,%20Microsoft%20provided%20Active%20Server%20Pages%20(ASP)%20that%20made%20it%20easier%20to%20create%20dynamic%20content.%20However,%20their%20solution%20only%20worked%20with%20Microsoft%20IIS%20or%20Personal%20Web%20Server.%20Therefore,%20if%20you%20wanted%20to%20use%20ASP%20you%20had%20to%20commit%20yourself%20to%20Microsoft%20products%20and%20you%20would%20not%20be%20enjoying%20the%20freedom%20of%20selecting%20your%20favorite%20web%20server%20and%20operating%20system!%20Another%20second%20generation%20technology%20that%20is%20quite%20popular%20in%20enterprise%20computing%20is%20servlets.%20Servlets%20make%20it%20easier%20to%20write%20server-side%20applications%20using%20Java%20technology.%20The%20problem%20with%20either%20CGI%20or%20servlets,%20however,%20is%20that%20you%20have%20to%20follow%20the%20write,%20compile,%20and%20deploy%20life%20cycle.%20JSP%20pages%20are%20a%20third%20generation%20solution%20that%20can%20be%20combined%20easily%20with%20some%20second%20generation%20solutions,%20creating%20dynamic%20content,%20and%20making%20it%20easier%20and%20faster%20to%20build%20web-based%20applications%20that%20work%20with%20a%20variety%20of%20other%20technologies:%20web%20servers,%20web%20browsers,%20application%20servers%20and%20other%20development%20tools.%20JavaServer%20Pages%20(JSP)The%20JSP%20technology%20is%20an%20open,%20freely%20available%20specification%20developed%20by%20Sun%20Microsystems%20as%20an%20alternative%20to%20Microsoft%27s%20Active%20Server%20Pages%20(ASP)%20technology,%20and%20a%20key%20component%20of%20the%20Java%202%20Enterprise%20Edition%20(J2EE)%20specification.%20Many%20of%20the%20commercially%20available%20application%20servers%20(such%20as%20BEA%20WebLogic,%20IBM%20WebSphere,%20Live%20JRun,%20Orion,%20and%20so%20on)%20already%20support%20JSP%20technology.%20JSP%20versus%20ASPJSP%20and%20ASP%20deliver%20similar%20functionality.%20They%20both%20use%20tags%20to%20allow%20embedded%20code%20in%20an%20HTML%20page,%20session%20tracking,%20and%20database%20connection.%20Some%20of%20the%20trivial%20differences%20are:%20ASP%20pages%20are%20written%20in%20VBScript%20and%20JSP%20pages%20are%20written%20in%20the%20Java%20programming%20language.%20Therefore,%20JSP%20pages%20are%20platform-independent%20and%20ASP%20pages%20are%20not.%20JSP%20pages%20use%20JavaBeans%20technology%20as%20the%20component%20architecture%20and%20ASP%20pages%20use%20ActiveX%20components.%20Beyond%20these%20trivial%20differences,%20there%20are%20a%20number%20of%20important%20differences%20that%20may%20help%20you%20in%20choosing%20a%20technology%20for%20your%20organization:%20Speed%20and%20Scalability:%20Although%20ASP%20pages%20are%20cached,%20they%20are%20always%20interpreted.%20By%20contrast,%20JSP%20pages%20are%20compiled%20into%20Java%20servlets%20and%20loaded%20into%20memory%20the%20first%20time%20they%20are%20called,%20and%20executed%20for%20all%20subsequent%20calls.%20This%20gives%20JSP%20pages%20aspeed%20and%20scalabmailto:?subject=Sun%20Web%20Page:%20Web%20Application%20Development%20with%20JSP%20and%20XMLPart%20I:%20Fast%20Track%20JSP%C2%A0%C2%A0Print-friendly%20VersionPrint-friendly%20Version%C2%A0%20Articles%20IndexBy%20Qusay%20H.%20Mahmoud(June%202001)If%20you%20have%20had%20the%20opportunity%20to%20build%20web%20applications%20using%20technologies%20such%20as%20Common%20Gateway%20Interface%20(CGI)%20and%20servlets,%20you%20are%20accustomed%20to%20the%20idea%20of%20writing%20a%20program%20to%20generate%20the%20whole%20page%20(the%20static%20and%20the%20dynamic%20part)%20using%20that%20same%20program.%20If%20you%20are%20looking%20for%20a%20solution%20in%20which%20you%20can%20separate%20the%20two%20parts,%20look%20no%20further.%20JavaServer%20Pages%20(JSP)%20are%20here.%20JSP%20pages%20allow%20you%20to%20separate%20front-end%20presentation%20from%20business%20logic%20(middle%20and%20back-end%20tiers).%20It%20is%20a%20great%20Rapid%20Application%20Development%20(RAD)%20approach%20to%20Web%20applications.%20This%20series%20of%20articles%20provides%20a%20hands-on%20tutorial%20explaining%20how%20to%20develop%20modern%20Web%20applications%20for%20today%27s%20and%20tomorrow%27s%20market.%20This%20series%20begins%20with%20this%20article,%20which%20explains%20the%20concepts%20and%20benefits%20of%20JSP%20technology,%20and%20then%20shows%20you%20how%20to%20utilize%20this%20exciting%20technology,%20and%20how%20to%20create%20reusable%20components%20for%20handling%20forms.%20The%20Dynamic%20WebThe%20Web%20has%20evolved%20from%20a%20network-based%20hypermedia%20distributed%20information%20system%20offering%20static%20information%20to%20a%20marketplace%20for%20selling%20and%20buying%20goods%20and%20services.%20The%20increasingly%20sophisticated%20applications%20to%20enable%20this%20marketplace%20require%20a%20technology%20for%20presenting%20dynamic%20information.%20First%20generation%20solutions%20included%20CGI,%20which%20is%20a%20mechanism%20for%20running%20external%20programs%20through%20a%20web%20server.%20The%20problem%20with%20CGI%20scripts%20is%20scalability;%20a%20new%20process%20is%20created%20for%20every%20request.%20Second%20generation%20solutions%20included%20web%20server%20vendors%20providing%20plug-ins%20and%20APIs%20for%20their%20servers.%20The%20problem%20is%20that%20their%20solutions%20were%20specific%20to%20their%20server%20products.%20For%20example,%20Microsoft%