SYS-CON MEDIA Authors: Liz McMillan, Carmen Gonzalez, Zakia Bouachraoui, Roger Strukhoff, David Linthicum

Related Topics: Adobe Flex, ColdFusion

Adobe Flex: Article

Streamlining Application Development Using Struts in ColdFusion

ColdFusion MX supports Java objects and servlets in a big way

Although earlier versions of ColdFusion supported Java objects and servlets to some degree, ColdFusion MX does so in a big way. This support opens up commercially available libraries to ColdFusion developers that were previously only available to J2EE shops. Moreover, you can now draw from an immense library of free code from within the Java open-source community. This availability greatly enhances the features of your own applications and speeds your ColdFusion-based solutions to market. Use these objects to provide back-end processing or user-interface functionality, or simplify coding CFM pages by supplementing ColdFusion functions and tags with Java TagLibraries.

Of particular note is how ColdFusion MX hosts and runs the Apache Jakarta Project's Struts Action servlet. By implementing Struts, ColdFusion MX offers a Model-2 Model-View-Controller (or MVC) environment for ColdFusion applications. This article is based on an implementation that uses ColdFusion MX Enterprise Edition on a Windows server. ColdFusion MX Enterprise Edition includes an embedded J2EE server based on Macromedia JRun. In addition to hosting ColdFusion pages, Enterprise Edition can host JSPs and servlets. This article is also applicable to users running ColdFusion on third-party application servers, although directory and filenames will vary somewhat.

First I give a brief description of my recent project, which shows how Struts and other Java objects provided a timesaving solution to a ColdFusion project. Next I explain MVC architectures so that you can define the role that Struts plays in your application's architecture. Then you learn how to transition your own development into a Struts framework. Finally I give you a sample application to help you get started using Struts in your own environment. (Code for this article can be downloaded from

Background: Saving Time with Struts
My Company: I work for a firm that creates websites and web applications for a wide range of businesses. We support many technologies, including Java and ColdFusion. On Java projects, we capitalize on open-source projects to speed solutions to market. Over the years, we have accumulated a large library of Java applications, objects, and services.

In the Java arena, we have adopted the Struts framework for our web services. By using Struts to implement a true Model-2 MVC architecture, we can split work among our various groups. Our layout group is fluent in designing dazzling layouts using Macromedia Flash. Our business managers design conceptual business objects and workflow. Our developers use Struts to create in code the objects and flow described by the business managers. While the members of each group have great talents in their assigned areas, they require a cursory understanding of the others' ingredients to a web-based application.

Our Client: One recent client was an internal ColdFusion development shop for a large association of plastic surgeons. Their task was to create web-based services for their membership. The members use these services to promote their private practices to the public. The success of these developers is measured by the number of referrals that are driven by the website to the doctors' private practices. To do this, the association strives to be a clearinghouse from which potential patients can find the best doctor for their needs.

They run their website on Windows servers running ColdFusion MX Enterprise Edition. (They also happen to run CommonSpot, a content management package from PaperThin. They often import ColdFusion pages into CommonSpot for consistency with the rest of the site. However, CommonSpot integration is beyond the scope of this article.)

The Project: We had to create private photo galleries that users could access from a doctor's personal page. Doctors publish their most successful procedures using before-and-after photographs along with a description of the procedure. The reason for this is so that the public will view these images and be encouraged to contact the doctor's office for a consultation.

In addition, the association wanted to offer a general-purpose gallery to the public. By drawing customers to the site, the association would lead patients to a doctor's private page and hopefully generate a referral. This general gallery would be a subset of the best examples found among the members' private galleries.

This project offered us many challenges. First of all, the images were categorized by procedure, each of which had a unique HTML form to describe the patient, treatment, and results of the surgery. This form needed to be converted into a descriptive paragraph suitable for public viewing. Some form of template-technology would be required for that conversion.

Second, the images submitted by the members were typically simple downloads from a digital camera. These images came in various dimensions and resolutions and needed to be resized to standard dimensions before being stored on the servers. Additionally, photos needed to be watermarked with some sort of copyright text so discourage web surfers from appropriating them for their own uses.

Third, we needed to build in all the sorts of features you expect to find in a good online photo-gallery service: grouping, indexing, filtering, and so on.

The ColdFusion and Struts Solution: As with any business, competitive concerns and published timelines required our client to roll out these new services quickly and reliably. The services also needed to match the look and feel of the rest of the website. In addition, the workflow was still being "worked out" as development began.

By using Struts, we enjoyed all the benefits of MVC architecture: Our layout team started designing the pages that reflected the look and feel of the existing ColdFusion MX site while our developers created the Beans that maintained the photo gallery pages. They also started building the generic structures for the procedure forms. We created and modified the process flow through simple modifications to the Struts configuration file, and each team created independent timelines and contributed pieces to the project as they became available.

Java object support proved to be a great timesaver. In our private libraries, we already had a Java object that used the Graphics2D class to quickly complete the image-modification features. We implemented Apache Velocity ( create the paragraph templates in record time. From an earlier contract, we already had a skeleton Struts service for creating a website photo gallery. In all, ColdFusion's support for Java and Struts allowed us to reuse code and work in parallel, effectively halving the time to complete the job.

(In all fairness, Macromedia technologies alone could have solved most of our requirements. ColdFusion pages, ColdFusion components, and Macromedia Flash components offer all the functionality we required. However, the ability to reuse open-source code, not to mention mine our private libraries, motivated many of our choices.)

Examining the Struts Framework's Usefulness
To understand what Struts is, it helps first to review the terms defining the Model-View-Controller (MVC) approach to application development (see Figure 1). When creating an application, the Model represents the information‹the logic‹that connects the information. To a Java developer, these roles are implemented by the storage media (such as database tables or data files) and the Beans that maintain them. To a ColdFusion developer, the model is supported by ColdFusion components and data sources.

The View is the interface used to present the model to users, or obtain input to maintain that model. To a web developer, this View is passed between web browsers and web servers as HTML pages and HTTP requests. Java developers create this interface using JavaServer Pages (JSPs), HTML, and JavaScript. ColdFusion shops use ColdFusion Pages (CFMs), HTML, and perhaps some JavaScript.

The Controller is responsible for directing traffic between and among the Model and View objects. As the View submits information, that information is passed to the Controller, which implements the proper Model object for manipulating or storing the data. The Controller might invoke a new View to provide user feedback on the Model's success or failure to process that information. Likewise, when the View requests information, the request is submitted to the Controller. The Controller calls the necessary Model(s) to get the information and then passes that information to an appropriate View object for display. How‹or perhaps I should say where‹this Controller function is implemented is what differentiates Model-1 and Model-2 implementations of the MVC design.

A full description of Model-1 and Model-2 MVC implementations can be found in Designing Enterprise Applications with the J2EE Platform, Second Edition by Inderjeet Singh, Beth Stearns, Mark Johnson, and the Sun Microsystems Enterprise Team. This book explains that in a Model-1 architecture, application flow is determined by the links embedded in the JSP or CFM pages; whereas in a Model-2 architecture, a servlet (Controller) is placed between the web pages (the View) and the business objects (the Model) to determine program flow.

So now with all that behind us, we can define Struts as follows: Struts is an implementation of the Controller functionality in a Model-2 MVC architecture.

The next logical question to ask is how do you apply these various roles of MVC architecture to the ColdFusion MX environment? And which ­ if any ­ of these architectures is appropriate for your project?

Applications created using JSP or CFM pages have a tendency to embed some of the business logic within the current page. Although it's possible to separate logic from Views, which are later combined using includes, it's not uncommon for developers‹especially during the final hours of development‹to embed small pieces of logic in the View layer. What's more to the point is that the command richness of both JavaServer Pages and ColdFusion MX allows developers to break rules. Because these types of applications are considered non-MVC conforming designs, they do not perform well over heavy loads. Non-MVC applications are perhaps most appropriate for prototypes and small-scale applications.

More Stories By Steve Belt

Steve Belt is a senior software developer for BrowserMedia, LLC, where he develops innovative software solutions for associations and finds new ways to use the Internet to make their lives easier. Before joining BrowserMedia, Steve led the development of several web-enabled tools and services used in the bioinformatics industry. Steve also participates heavily in several Java open-source projects.

Comments (1)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Latest Stories
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
ScaleMP is presenting at CloudEXPO 2019, held June 24-26 in Santa Clara, and we’d love to see you there. At the conference, we’ll demonstrate how ScaleMP is solving one of the most vexing challenges for cloud — memory cost and limit of scale — and how our innovative vSMP MemoryONE solution provides affordable larger server memory for the private and public cloud. Please visit us at Booth No. 519 to connect with our experts and learn more about vSMP MemoryONE and how it is already serving some of...
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understa...
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility. As they do so, IT professionals are also embr...
Platform9, the leader in SaaS-managed hybrid cloud, has announced it will present five sessions at four upcoming industry conferences in June: BCS in London, DevOpsCon in Berlin, HPE Discover and Cloud Computing Expo 2019.
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
When you're operating multiple services in production, building out forensics tools such as monitoring and observability becomes essential. Unfortunately, it is a real challenge balancing priorities between building new features and tools to help pinpoint root causes. Linkerd provides many of the tools you need to tame the chaos of operating microservices in a cloud native world. Because Linkerd is a transparent proxy that runs alongside your application, there are no code changes required. I...
In his general session at 21st Cloud Expo, Greg Dumas, Calligo’s Vice President and G.M. of US operations, discussed the new Global Data Protection Regulation and how Calligo can help business stay compliant in digitally globalized world. Greg Dumas is Calligo's Vice President and G.M. of US operations. Calligo is an established service provider that provides an innovative platform for trusted cloud solutions. Calligo’s customers are typically most concerned about GDPR compliance, application p...
Modern software design has fundamentally changed how we manage applications, causing many to turn to containers as the new virtual machine for resource management. As container adoption grows beyond stateless applications to stateful workloads, the need for persistent storage is foundational - something customers routinely cite as a top pain point. In his session at @DevOpsSummit at 21st Cloud Expo, Bill Borsari, Head of Systems Engineering at Datera, explored how organizations can reap the bene...
"NetApp's vision is how we help organizations manage data - delivering the right data in the right place, in the right time, to the people who need it, and doing it agnostic to what the platform is," explained Josh Atwell, Developer Advocate for NetApp, in this interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
Kubernetes as a Container Platform is becoming a de facto for every enterprise. In my interactions with enterprises adopting container platform, I come across common questions: - How does application security work on this platform? What all do I need to secure? - How do I implement security in pipelines? - What about vulnerabilities discovered at a later point in time? - What are newer technologies like Istio Service Mesh bring to table?In this session, I will be addressing these commonly asked ...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.