|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Flash An Alternative to JavaServer Pages?
Might Flex offer higher ROI and better impact?
By: Peter Ent
Oct. 13, 2004 12:00 AM
I am a Web application developer. That can mean a number of things these days, but in my case, it means I write code on both the client and the server to make a complete "application." For many of us, the client-side code is JSP - JavaServer Pages. Perhaps, like me, you find JSP to be awkward with its mixture of languages and styles. I also find developing large applications to be ever more complex as I add packages such as Struts and Tiles, which are intended to make using JSP easier. A few years ago I started to learn and use Macromedia Flash because I read it had the ability to send and receive information via HTTP. I saw Flash as a way to avoid using JSP to write Web applications. This turned out to be a good idea. However, it quickly became obvious that using Flash was not going to enable the other members of my group to easily join me in creating a new generation of applications. This is because Flash has a steep learning curve. While most business-like applications do not require animation, you still have to learn the Flash IDE and become familiar with how application development is done with Flash. The Flash MX release included a set of predefined UI components (such as combo-boxes, lists, and buttons) to speed application development. Even with the newest version, Flash MX 2004, there is still a learning curve issue. For instance, to build a respectable application, you have to understand how Flash movies are produced with their layers of movie clips and timelines. For a while I resigned myself to the fact that my team members might have to become Flash developers. I met some resistance to this idea, but there didn't seem to be any alternatives. I had been reading about Macromedia's new product, Flex, and for a while considered joining the beta effort, but I was too busy writing Flash applications to take part. Once I got a trial copy of the first release, Flex changed how I view Web application development. What Is Flex? If you are familiar with JSP technology, Flex will not seem too dissimilar. Just as with JSP, server-side technologies are employed to deliver information to the end user; raw "source" files exist on a server and are converted on-the-fly by server-side components into a form presentable by a browser. But the similarities between Flex and previous technologies end there. Macromedia Flex delivers Macromedia Flash applications, not HTML, to the end-user's browser. The Flash player, a plug-in to the Web browser, renders the Flash application. Figure 1 shows the Flex process in detail. Notice how similar it is to how JSP operates.
As the user interacts with the Flash application, calls are made from the Flash application to remote objects - via either Web services, XML documents, or JavaBeans, residing on servers. Flex produces "smart client" code. Thin clients, such as Web browsers, place most of the processing duties on the server. Data validation (which is possible with JavaScript on the client), calculations, localization, and such are best done at the client's computer and make the most of the processing power there. With Flex, the client can sort their data, have it formatted to their liking, print reports, and interact in new and meaningful ways that were not possible with previous Web technologies. Examples
One of the issues I have with JSP is that it is possible to have a single file that contains a mixture of languages and programming styles. For example:
It is hard to have a clean separation of client-side (or user interface) code from server-side (or business) code. For example, it is possible with JSP to write a JavaBean that produces HTML in the course of executing business logic. A lot of effort has been put into making JSP development more palatable. Business logic developers can create tag libraries for Web developers to use when coding JSP files. This supposedly helps separate the user interface code from the business logic code. One of the more common packages developed for this purpose is Struts from the Apache Software Foundation. Struts is an attempt to apply some software methodologies to the complexity of JSP development. The business logic developers create a series of forms and actions that process input from the JSPs and forward the results to other JSPs; this is put together with configuration files written in XML. In addition, for user interface code reuse, there is the Tiles package, also from Apache. This allows a Web page to be broken into rectangular sections ("tiles") described by configuration files and implemented with JSPs. Nonetheless, with all of this effort you can create pretzel-logic Web code that can be difficult for project newcomers to untangle. The Flex Way There are several benefits to this:
Sample Application JSP Example To make this program work, the "Get Employee List" button (see Figure 2) submits the form data (the combo-box selection) by invoking itself. I find this self-referencing logic to be confusing, especially on large projects. Flex Example If you have ever written a JSP to produce a table that the end user can sort, you know how complex this can be. HTML provides no way to sort a table, nor any way to indicate that a table has been sorted. The power of Flex lies in its ability to create applications that can run independent of the server (see Figure 3). For instance, to sort the data in a table the user just clicks on a column heading. The Flex DataGrid is more powerful than an HTML table: it has the capacity to sort its data without needing to contact the server. Flex makes it easier for developers to add features to applications, such as sorting a table; with JSP, features like this may take days to complete. Comparison Chart Not a Panacea Keep in mind, then, that Flex and JSP can happily coexist. Conclusion Consider also that JSPs were once the "new technology" and were, in fact, created to fill the need of bringing dynamic content to the Web. I feel Flex is the next step in the evolution path of Web-based applications. Flex extends this path by bringing richer applications to the Web in a way that is easy to develop and maintain. The return on investment with Flex is higher than with JSP (and Java applets) because more time is spent developing useful applications than is spent resolving compatibility issues. Resources
Reader Feedback: Page 1 of 1
Your Feedback
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||