首页>ASP文摘教程>文章详情

jsp强于asp,但不是asp.net

4/26/2001
20325
By Corey Roth, Senior Web Developer
Special to ZDNet

Fo r a while, the Java 2 Enterprise Edition (J2EE) architecture looked like the best way to develop multi-tiered applications. Java Server Pages (JSP) and servlets had many advantages over the Active Server Pages (ASP) and Component Object Model (COM+) platforms. However, I think that is about to change with Microsoft .Net on the horizon. Microsoft .Net is providing a similar platform but with more functionality, and it quite possibly could have the foundation for being cross-platform at some stage. According to Sun, JSP is better than ASP for the following reasons: It has platform and server independence, it has extensible JSP tags and ASP is interpreted. Luckily, ASP .Net changes all of this.
The biggest argument why Java is superior is that it is a cross-platform environment. Having cross-platform is great, but at what cost? Java is slow by design. With Java, every time you run your program it goes through the Java Virtual Machine, an interpreter, which then converts the Java byte codes to native code. Microsoft may end up having support for platform independence with the way programs are compiled with Microsoft .Net.

When a program is compiled with .Net, it is compiled into a DLL or EXE in Microsoft Intermediate Language (MSIL) format, a processor independent assembly language. MSIL does not contain any dependencies on any particular operating system or architecture. The first time this EXE is executed, it uses Just In Time (JIT) compilation to convert the MSIL into native code. So the first time you run it, it may be slower, but subsequent executions will be faster. As you can see, this has the potential for adaptation to a cross-platform situation, but Microsoft hasn't made any promises of that yet.

Now, I don't know if Microsoft will ever actually convert .Net to work on other platforms, but they are putting the support in there for it. My response to cross-platform is: Who cares? For Java, all that means is that it works on 50 different types of Unix. As far as I am concerned, the Intel platform is the only one that is worth bothering with. Designwise it may be inferior to the Sparc or Alpha, but the Intel platform is the only one Microsoft develops for.

Of tags and scripts
ASP 3.0 does not have extensible tags, an advantage that JSP has held over ASP for quite some time. Now with ASP .Net, extensible tags are available. Through the use of Web Forms, ASP .Net is able to do data binding, form validation and more without the developer having to write any script at all. Developers even have the ability to write their own custom Web Form controls to suit their own needs.

Another problem in the past with ASP was that it was an interpreted language, whereas JSP pages are compiled into servlets the first time the JSP page is accessed. What Sun neglects to mention is that the servlet is still interpreted with the Java Virtual Machine. With ASP .Net, pages will now be precompiled to MSIL and then use JIT compiling, just like JSP. The difference is .Net gets compiled once into native code, and servlets are interpreted every time they are executed. In the long run, I think this will result in .Net code being more efficient.

Microsoft's .Net may not be perfect. Since it still is in beta, it may change quite a bit before it is actually released. However, I think it is a great alternative to what we had before. In the past, using COM and the Microsoft Transaction Server (MTS) was a nightmare for developers and using J2EE was slower than death. I admit for a long time, the J2EE platform was superior to ASP and COM+. With .Net coming soon, Sun should be looking for new ways to improve its platform and remain competitive. Otherwise, it may be losing future developers.

Corey Roth is a Senior Web Developer for Word Spinners, a Tulsa, OK-based Web development company. He has five years of experience in developing Web sites, and started his Web development career at Creative Labs. Corey is also considered a local expert in Microsoft technologies, including Active Server Pages, COM+ and Microsoft Site Server.

Disclaimer: 'Your Turn' is a commentary column written by a ZDNet News reader. The opinions expressed herein are those of the author, not those of ZDNet, ZDNet News nor its editors.