Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not a News Clip but an Excerpt from a Developer...

Status
Not open for further replies.

etrain

Programmer
Aug 3, 2001
65
US
I received this in an email a while ago and until now it did not mean much because I was not seriously looking to develop a web site.

This goes inline with a previous post of mine title "Website Development Where to Begin..." From reading this my ideal choice seems to be PHP and Access.

Please read through and provide any feedback, good, bad or indifferent.

If nothing else it seems to provide some insight but not knowing the technology I can't really give my owned informed opinion.

--Start of Excerpt--
This e-mail is to clarify certain concepts as to web based application development with JSP, Java, and PHP.



Synopsis:

The e-mail starts off with a description of what a web-based application is and explains the Model/View/Controller design pattern as applied to web systems. Then it takes on JSP, giving examples of how it fails to deliver on its promises. And finally, it gives better alternatives: PHP - another template system, and Turbine/WebMacro – a platform for building servlet-based systems.





A web-based application

A web-based application is an application where users use their favorite web browser to securely communicate with a web server to access business logic embedded in an application server.



Model/View/Controller

Model/View/Controller design pattern (MVC in short) is an architectural model that tries to divide web-based systems into three pieces, all for the sake of making large-scale projects more manageable. Back-end database, and core business logic is encapsulated in objects (or some other constructs) called models. Objects or other constructs called views control the look and feel of web pages. All the rest, i.e. managing sessions, tracking users and sessions, connection management, load balancing, and other housekeeping chores are done by controllers.



JSP

JSP is a template system. You mix html code and java code in a template page. When a request comes, the java code is executed and returns output that is combined with the html code, which is then sent to user browsers. There are other template systems, too. ASP uses Visual Basic to write custom code, and PHP uses a language similar to C. JSP was created as a direct response to the need of coding quickly web pages with Java, without the overhead associated with servlets.



Problems

JSP had a tremendous amount of marketing as Sun wanted to wean people off of ASP into the Java world. Partially, it was a success. All in all, however, JSP creates more problems than it tries to resolve. You get to write JSP template pages quickly, but only to realize that the line between content and presentation gets blurred. JSP evangelists will be quick here to let you know that tag libraries will help avoid the problem…. Well, as somebody put it: “JSP pages may look [then] like a grotesque Java reimplemented with tags”. Java code is too tempting; you will start intermingling your presentation code with business logic. You will create a total hodge-podge. If you take a look at the JSP code (and please do if you have not), you will see that the mixture of HTML tags, JSP tags, and java code is not really clear. Add to it some DHTML, and I bet you will find yourself spending hours debugging simple JSP pages.

“JSP page syntax errors can cause surprisingly odd and useless error messages. This is due to the fact the page is transformed into a servlet and then compiled. […]

What's wrong with the following?

<% static String title = &quot;Global title&quot;; %>
Well, the Tomcat reference implementation for JSP says this is wrong:

work/%3A8080%2F/JC_0002ejspJC_jsp_1.java:70: Statement expected.
static int count = 0;
^
Page designers won't recognize this error, and programmers likely won't either without looking at the generated source”

In essence, simple tasks in JSP are more difficult than they should be. JSP advocates realized that and try to find a solution. One of which is following the MVC design model. JSP does claim to support the MVC architecture. In fact, JSP promoters came up with the name Model2 for JSP. If you are not familiar with it, read the article: Well, this Model2 for JSP looks quite enticing from a first sight, but in reality it is nothing but hype. It does not remedy all the problems described above and in the following articles presented by the two renowned Java advocates.




“So is there a place for JSP in the future? Certainly. JSP is entirely relevant if what you're trying to do is wean people off of ASP. There's an extremely strong argument for providing something familiar looking in a new environment. This was one of the big motivations behind the creation of JSP, and that shows from the name -- it's no coincidence &quot;JSP&quot; is just one letter off from &quot;ASP&quot;. […] However, that doesn't make it is the best solution for the Java platform. That makes it the Java solution that is most like the non-Java solution.”




“An old Java technology hand and new Enhydra partisan, the author urges developers to consider alternatives to JavaServer Pages (JSP) servlets when choosing an approach to coding Web applications. JSP technology, part of Sun's J2EE platform and programming model, serves as a solution to the common dilemma of how to turn drab content into a visually appealing presentation layer. The fact is, Web developers aren't uniformly happy with JSP technology. Since many variations on the Sun technology are now available, you can choose from a number of presentation technologies. This article takes an in-depth look at JSP coding and explores some attractive alternatives.”

“JSP allows Java code to be inserted into the markup language page, and this rather dangerous feature allows content to be intermingled with presentation. Even worse, business logic often makes its way into JSP pages”

“As long as JSP coding allows inline coding, it is very convenient (especially when deadlines are looming) to make last-minute changes with inline code, rather than converting the code to a tag library. If this doesn't ring true, consider why the Java language immediately gained popularity over C and C++: Java disallowed many of the features that were problematic in C, such as pointer addition. While you can always argue that you don't have to perform pointer addition in C or that no good programmer would ever insert code scriptlets, we all know what happens in practice. The Java language is a better language because it mandates that these sorts of bad habits never surface. But JSP in this case is much like C, allowing some very bad practices.”





Competition

How does JSP stack up against the competition? Due to quite inefficient memory management, disk management and the fact that JSP pages are converted to java servlets, JSP cannot run faster than pure java servlets. According to some benchmarking tests that I have found (I will provide the link once I have found it again if you are interested), Java servlets are almost two times slower than ASP, and four or more times slower then PHP or Perl. PHP and Perl were the fastest. What about the reliability and ease of use? I guess the best indicator is the popularity of the technologies. The following link to Security Space provides some insights. According to it, the most popular Apache module: PHP has 45.98% of market penetration, Perl has 13.18 %, and Jserv (servlet engine which is also the core application engine in the Oracle Application Server) has 4.05%. I have not found the data about the Tomcat, which is the Apache module that supports – besides pure servlets - JSP. (Maybe you can find it at ?) As a matter of fact, I was not able to find any statistical data about JSP popularity, either. Does it mean that some excellent technology, like JSP, remains unrecognized? Maybe, but personally I doubt it. For me it means, that JSP most likely does not measure up.



Positives

The good thing about JSP is that you do not have to use it. You have alternatives.



PHP

If you need a template system, then I strongly recommend - PHP. It is fast to run, fast to write, and fast to learn. Technology-wise, PHP is by far the best system for developing applications of moderate complexity (do not confuse it with functional sophistication, though; you can build with PHP quite functionally-advanced applications). PHP stands out among other popular template systems, like JSP, or ASP. It is superior in almost every respect.



Perl and Java

Only when PHP does not satisfy your technological requirements, should you consider other solutions based on Perl or Java. These languages are so powerful, that you should be able to build any web application that you can think of. I like Perl, but not everybody so. Perl is a highly idiomatic language in a degree not seen before. Therefore, Perl can be a powerful tool in the hands of an experienced developer, but it is also a two-sided sword. Novices can hurt themselves. Java, … everybody knows it. And this is its edge.



Turbine/WebMacro/Tomcat

If you have to have Java, because your customer heard about it and says it is the future, then I recommend a servlet engine -Tomcat, with Turbine and WebMacro. Turbine is a servlet-based framwork, or platform, for building applications, not running them. It imposes certain design patterns, but at the same time provides many services for free. You do not need to implement session management, connection pooling, parameter parsing, failsafe job-based scheduler system, generic services for creating singletons and other services. You’ve got them for free. WebMacro is free, too. It is a highly specialized template system that formats a set of back end Java object into HTML. Different templates can return to the user different content or look and feel. In short, WebMacro hooks up your Java objects with your templates. Turbine together with WebMacro neatly separates presentation, business logic, and controlling mechanisms. Actually, there is a preconfigured Turbine Developers Kit (TDK), which is a combination of Tomcat, WebMacro, and Turbine. For further information please refer to the following excerpts and links.



“[…] any commercial (and non-commercial!) software companies will attempt to sell you an &quot;Application Server&quot;, but what few people realize is that it is only half of the battle to creating a web application. There is often quite a lot of code that your engineers end up re-inventing the wheel with or grabbing various packages from all over the net with various licenses that you may or may not agree to. “

“The point of Turbine is to collect that code into one location and make it easy to create re-usable components (such as ParameterParsing, Database Connection Pools, Job Scheduling, GlobalCaches, integration with other tools such as Castor, Velocity, Webmacro, etc...) all under a license (Apache) that allows you to create useful websites for your customers without worrying about viral code. Turbine is not the end all answer, but it sure is a nice way to make your development life easier. “

“This framework has an intended audience that is directed at web engineers, not necessarily the web designers. By using this framework, it is possible for the web engineers to build intuitive high-level systems for the web designers to use, but the low level framework is strictly for web engineers. Turbine is not a web application server. It is a tool for building web applications. Your servlet engine is your application server and the application that you develop using this framework is your web application.“





--End of Excerpt

Remember the Past, Plan for the Future, yet Live in the Present for tomorrow may never come.
-etrain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top