Back to Papers and Articles
Tagging Along with ASP.NET, JSP and ColdFusion
Copyright 2002 Paragon Corporation   ( October 07, 2002)

What are Server-Side Tags and their benefits?

Server-side tags are similar to HTML tags except they are processed by the web server instead of the client browser and they ad-here more to the pure SGML-XML standard. Server-side tags really fall into 2 main groups.
  • Those that have a visual look - these tend to generate html that can be digested by the client
  • Those that have no visual interface, but perform some sort of function such as accessing a database or sending an E-mail etc.

You can think of server -side tag programming as another category of programming or subset of component programming. First came Procedural and functional programming, then came event-driven programming , object-oriented programming, then came component programming and now server side tag programming. Even though different programming approaches came at different times one approach is not necessarily better than another. In fact several approaches complement each other and you will find modern programming styles may combine several of these within the same application. Each approach is well-suited for a set of problem domains and certain languages are better for one set of approaches than another.

There are a number of benefits to using tag programming in a web environment over other programming styles. These benefits are listed below.

  • Server tags look similar to html tags so most WYSIWIG tools will not scramble them as they tend to do with procedural statements and functions.
  • With the above, Server tags provide a better separation of design from logic. E.g low level API programmers can develop server tags that are consumed by web designers and business domain programmers and such. The server tags contain within them how they will be rendered on different devices, authentication schemes. Variable attributes such as color style, email address etc, can be set in the page by a page designer or a business domain programmer. So a server tag black-boxes a lot of logic for common tasks or complex tasks that can then be deployed. The tag attributes allow users of tags to easily customize the behavior of a tag when outputting content or executing a common business function such as querying a database or sending out emails without having to recompile code or touch the tag. Tag programming is in essence an extension of component programming ; it is just a different way of presenting a component.
  • Because server side tags look similar to HTML - many html editors have built-in support for them - e.g Dreamweaver, WebMatrix, Visual Studio.NET etc.

    We will take a closer look at three programming architectures with heavy support for tag programming. We will focus on the latest offerings of these. Specifically Microsoft's ASP.NET, Macromedia's ColdFusion MX and Sun's Servlet/JSP/J2EE.

    How do they differentiate themselves

    Allaire ColdFusion - now Macromedia ColdFusion - was one of the first products to propose a tag approach to web programming and it's new MX product still is founded on this approach, but adds another key feature to the mix - that of Cold Fusion Components (CFCs). Sun caught on to this tag fever with the introduction of JSP Tags. Microsoft didn't move deep into this until ASP.NET. ASP had what were called runat server object tags which were not quite as flexible as the tags in ASP.NET or JSP and Cold Fusion tags and relied on a com object in the back end to support the tag.

    If one could describe in a nutshell how each differentiates themselves - it would read as follows

    Cold Fusion - Cold Fusion's basic theme still remains - make it easy for the web designer or business domain developer to create complex web applications with ease (with a language that looks like HTML) - make the common tasks easy at a slight expense to less common tasks. Cross-platform is important to Macromedia, so you will find that Cold Fusion runs on numerous Oses and web servers. Cold Fusion is still predominantly a tag-based architecture. It has tags for even doing conditional logic similar to how XSL works.

    ASP.NET - Cross-language first and cross-platform last. Make web programming look like good old RAD Windows programming. Give developers different languages to choose from when developing web apps. Make it difficult to write spaghetti code. Make it easy for new program components to be deployed without fussy installations. ASP.NET marries procedural programming with tag programming. Procedural programming is still a big component of ASP.NET and ASP.NET does not come with conditional logic tags like you find with JSP and Cold Fusion, but server tags now share the lime light as a very integral part to this technology. ASP.NET sports a rich library of web form tags for doing things like rendering paging data grids, list boxes, text boxes, web form field control validator tags etc. On top of that ASP.NET shares the many of the same set of libraries with the rest of the .NET architecture and the new event-driven capabilities make it feel very similar to good old Windows form programming.

    Java Servlets/JSP - Cross-platform first and cross language last. Try to do things the right way - to the book. Breakup up developers - Web designers and Business domain programmers develop with JSP and low-level API programmers and Advanced/Business domain Programmers develop using Java Servlets and Java enterprise beans. Your choice of server programming languages in JSP is still limited to Java in JSP (some variants of JSP allow Java script). Still JSP/Java Servlet relies on Java as the glue to put things together and trying to use non-java based components is a bit messy.

    More about the new Features

    Cold Fusion Cold Fusion still remains dedicated to the Business Domain programmer and web designer with it's easy to follow tag-based approach to programming. The new Cold Fusion MX adds a slight twist to this to cater to more advanced developers and enterprise corporations that want a more organized style of programming. Cold Fusion MX can compile to Java Servlets (similar to the way JSP does) and runs on top of many Servlet Engine enabled Web Servers. It also has a mechanism for using JSP tags in the cold fusion environment. On top of that they've introduced Cold Fusion Components (CFCs) which provide an Object-oriented dimension to Cold Fusion. CFCs are basically web services that can be the building blocks of more complex applications. They contain a set of web methods that can be invoked with the new CFINVOKE tag. In fact, you can use the CFINVOKE tag to call any web service regardless of whether it is written in Cold Fusion or not.

    CFCs are also just about as easy to write as your old standard CFML tag libs. In fact you will find that Cold Fusion MX does not make much of a distinction between Web Services and single application CFCs. The lines have been intentionally grayed. The new Cold Fusion MX vision seems to be to build applications using Web Services as building blocks. View each application as a loosely connected set of web services. Cold Fusion is betting very heavily on the new Web Services technology being the new standard of web programming.

    ASP.NET - Microsoft has moved leaps forward with ASP.NET from ASP. The main features that ASP.NET brings to the table that ASP lacked or was not as mature in - are below
    • (A new VB - VB.NET (not VBScript) and complex error-handling using the Try and End Try, short-circuit logic borrowed from languages like Java and choice of other .NET languages such as C# (a favorite among those who prefer the JAVA/C programming style) .
    • True page compilation - ASP.NET is not interpreted as was it's ASP predecessor, but instead - Microsoft has followed suit with Sun's JSP; code is now compiled into the .NET Common Language Run-time (CLR) - similar to Java's Virtual Machine and then further compiled into native machine code.
    • Windows event model and form field properties to the web environment (this new change makes it surprisingly easy to separate html from complex business logic and in fact difficult to mingle the two (a good thing actually). Instead code is triggered in event and function nuggets in html server controls or by databinding properties of run at server controls. In fact you can set any html element to a run at server element which allows one to programmatically change an html element (e.g. hiding rows divs - server side) before rendering it or databinding it to datasets data readers etc..
    • View State - ASP.NET now has the concept of View State - where each html element can remember it’s previous state from form post to form post. This is optional and can be turned off by element. This allows text boxes, listboxes etc. to remember what was selected in the previous post and automatically set these when displayed back to the user.
    • Code Behind - This allows one to further separate business logic from page design. In simple terms though - Code Behind is really nothing more than good old object inheritance - where the complex logic is defined in one class and the visual page or visual control simply inherits it's behavior from this class but provides the design. Page design is kept in an .aspx, .ascx, or .asmx file with a line at the top that states it will inherit or use code behind (specifying the class providing the code behind) and the business logic is kept in a .vb, .cs or other .NET programming language file (there are numerous .NET languages in beta right now PERL.NET, Delphi.NET SmallTalk.NET etc.). Currently only VB.NET, C Sharp, and J++ can be used directly inside a .aspx file - other languages must use code behind.
    • Server Tags, User Controls- similar to the CFML Tags and JSP Tags. True server tags require more complex programming while User Controls can be in .ascx files and are relatively easy to create. Once created - user controls are used like any other tag - and can have their properties set via tag attributes. Server control programming is generally done for very generic complex logic (such as the ASP.NET datagrid and datagrid subclasses and specialized kinds of form fields) - while user control programming is done for more specific logic that pertains to one particular application (e.g. a navigation menu - a detail row).
    • A framework for creating Web services that is relatively easy to apply (.ASMX) that automatically handles the conversion from XML to object and Object to XML for you.
    • Built-in complex web server caching capability - with just a line of code you can do things like dictate how long a web server should cache data, based on what variables and whether whole page or just particular web control caching.

    VB.NET is not your old VB; it is truly VB reinvented. The new VB is more like a marriage between VB and Java. VB.NET utilizes the same rich namespace library that C Sharp and other languages can use. It now supports inheritance. The SET, LET and Variant keywords are gone so everything is now an Object. It has incorporated the complex error handling Try Catch syntax that Java and C have as well as short-circuit boolean logic using the new keywords AndAlso and OrElse. In old VB a condition would have to be completely processed which meant often writing additional conditional subloops to prevent runtime errors. With short-circuit programming - one can write statements such as If dr.Read() AndAlso dr("id") > 5 Then In old style VB - you would get a runtime error if your data reader had no records becuase it would process both parts. With this new short-circuit syntax - the second clause is not processed because the first clause evaluated to false. This also saves processing time.

    The new language C Sharp (C#) - is also a bit of a morph too. It has the new foreach clause as well as the controversial goto clauses (both borrowed from VB) that Java lacks and utilizes similar event handling glue of VB (and other languages like Delphi). It's switch statement behaves more like the VB Select Case statement than it does like the Java switch in that it doesn't require each case to be an integer (can be a string like VB) . It has a rich library (shared with VB.NET) - called Namespaces. This is equivalent to Java’s J2EE packages.

    The big message though that Microsoft is making with the .NET architecture is the statement of cross-language first and cross-platform last. Microsoft has provided their windows implementation of .NET as a reference implementation and submitted .NET to ECMA - and left it up to 3rd parties to develop this architecture on other platforms.

    You can mix and match languages within a single ASP.NET app and use other components developed in other languages (and as bad as that sounds - it works surprisingly well and is relatively transparent since all .NET languages get translated to the .NET CLI). This means that if you like a component that one set of developers creates - you don't need to worry too much about the fact that the component is not written in your preferred language - as long as the logic is well black-boxed. ASP.NET does not work on all platforms YET; this appears to be changing with 3rd parties however like Covalent with there .NET Apach Server product and the new Open source Mono project to name a few.

    JSP/Servlet

    Sun's JSP/Servlet technology has changed least of all. It still remains pretty much as it was a year ago - the Java Servlet 2.3 standard has added very little - except for modifications in use of Filters. J2EE and the very important JDO (Java Data Objects) has matured a bit and Java Enterprise beans have become more complicated and better integrated with JSP/Servlet. Java Enterprise beans still remain too complicated to easily implement for your standard web app unless you accomplish it via third party products such as Cold Fusion, so is hard to keep up with the "I needed it yesterday mentality of today (Internet Time)." It must be noted that J2EE/Java Enterprise Beans and Servlets do not necessarily go hand in hand. In fact most Servlet sites do not directly use Java Enterprise beans and do just quite fine.

    There is one major feature that Sun has added to JSP which is probably a relief to many. This is the JavaServer PagesTM Standard Tag Library (JSTL). JSTL is a spec like all other Java specs, but defines specific tags how they will be named, their signature (what inputs and outputs they will take and return). Third parties are free to provide their own implementation of this that will work best with their servlet engine.

    Why is this so good? When JSP came out, it was very limited in terms of tags provided (Cold Fusion and ASP.NET on the other hand have a rich tag library out of the box for common tasks). This meant relying on the proprietary tags provided by third-party vendors which were often integrated with the Servlet Engine they sold you and had its own non-standard set of tags each with its own non-standard set of properties etc, or going through the very time consuming process of rolling your own tags. Change your servlet engine and well you’re out of luck because the tags you used and loved could not be ported to another engine. This ruined the write once run anywhere mantra of JSP. The Apache struts library (now called Jakarta TagLib) did do a lot to provide common tags that would be useable everywhere, but still tags provided by third-parties such as Macromedia JRUN, BEA Logic etc. were still a bit easier to use because they were automatically installed and ready to use with your servlet engine, often worked better with their servlet container because they were specifically designed to work with the idiosyncracies of your servlet container and some were just more extensive in functionality. It was hard to not take the candy dangling above you even though it would give you cavities.

    With the introduction of JSTL - hopefully this will change. In fact the Jakarta TagLib is a reference implementation of JSTL now. Hopefully servlet container providers will follow suit and provide tags taht are JSTL compliant. It’s still too early to say how well this will work out, but it looks promising.

    Links of Interest

    Source Forge Provides a workspace for open source projects. It has everything - Cold Fusion, ASP.Net, Unix, Linux, Mac.
    The Mono Project A project that is working on creating an Open source implementation of the .NET architecture. Parts that are functional currently work on Linux, Windows, and Solaris.
    411 ASP.Net Directory ASP.NET resource site containing how-To articles and hosting and list of ASP.NET consultants
    JSPTags JSP Tag resource site - full of freee and inexpensive JSP tags
    Code Project Resource of how-to articles and code snippets for the .NET architecture. The site mostly focuses on C#.
    Introduction to Cold Fusion Components Article by Ben Forta describing what CFCs are and how they are sued.
    CF Lib A repository of free User-defined Functions (UDFs) for cold fusion
    Servlets.com Site maintained by Jason Hunter. It focuses on the state of JSP and servlets and Java in general.
    Faster Development with JavaServer PagesTM Standard Tag Library (JSTL 1.0) An article describing what JSTL is, its purpose and how to use it.



  • Back to Papers and Articles