Hi all,
 
I am following a variety of discussions about using servlets vs JSP vs Template Engines. But there is a combination that seems nobody have mentioned, and I am wondering why.
 
Why don't use servlets or JSP pages to create request processing and simple javascript files with only variable declarations, and use static HTML files for the rest?
 
Of course, for this to be a good design style, we need our designers to know javascript. And of course, this is not always true.
 
I don't pretend to say it is a perfect solution for all situations. But wherever we have the appropriate people, it seems to me that it can be a very productive combination. Let me expose an example:
 
We need to create a products list page, in which we have to present a description (with a link) and a price for each product.
 
The first step would be to specify our javascript file content. We can define it with an example. In this case, it could be something like:
 

var products = new Array();
products[0] = new Array("description", "link", price);
products[1] = new Array("description", "link", price);
...
 
Including such a javascript file in a static HTML page, the page have information enough to render itself (of course, through javascript).
 
Create a servlet/JSP that produces a file like the one above is a trivial work.
 
The major advantage comes when the designer have to create the HTML page. We can provide a full set of static javascript files like the one above. This way, the designer can forget about the developers. It can test the pages even without the need of a web server. It can do all his job in his local filesystem.
 
The disadvantage of this methodology is the need of a designer with javascript knowledge. But the javascript needed to access to the values that come from our servlet is very easy; roll-overs and layer animations are more complicated than this. The designer does not need to be a javascript guru.
 
Nowadays, only a small group of internet users deactivates javascript in their browsers. Javascript is so used in DHTML pages that there is no point in deactivating it.
 
The advantages, when the condition of "designer expertice available" is true, are evident (at least to me :-):
  • Developers and Designers work are totally independent, after agreement in javascript format.
  • Changes in the page layout will not affect to the generation code.
  • The bulk of the page is now static, so it takes full advantage of the browser cache system. Only the data part is dynamic, and it's separated from the rest. This is the most important improvement over template engines.
  • The result from servlet/JSP execution is a smaller file than the equivalent with the traditional approach. It's also usually faster to
  • The implementation of the javascript code generation is far simpler than the whole page generation. Implementation is done faster.
  • Pages can be tested out of the server.
  • Javascript code generated with the servlet can be easily validated. We only need to point our browser to the javascript URL, and it will show us the found syntax errors.
  • An important part of the presentation task is left to the browser. This can improve our server performance, as it serves requests more quickly. It will support more concurrent connections.
I understand that more than a few projects can benefit from this approach. Have anyone experimented something similar before?
 
Thanks,
--
GRIDSYSTEMS                    Rodrigo Ruiz Aguayo
Parc Bit - Son Espanyol        Ingeniero II
07120 Palma de Mallorca        [EMAIL PROTECTED]
Baleares - España              Tel:+34-971435085
www.gridsystems.com            Fax:+34-971435082

Reply via email to