JSP Insider - http://www.jspinsider.com

News - Articles/Tutorials/Code/Reviews - JSP/Servlet Hosting Companies - Links

JSP Buzz 03/27/2001 - Intro to Struts

***** IN THIS ISSUE ************************************************** 
News
1:Beta Release of Java 1.4
2:Macromedia Completes Allaire Merger
3:Microsoft Vexed by Falsified Certs

Rambles 
1:JavaScript Debugging
2:Some More on XML and JSP Design
3:JSP in Other Languages
4:Internet Dust in the Wind

Links 	
1:WebJava Advanced List Serv
2:Java Web Applications
3:Anti-Mental Domination Devices
4:Make Bad Code Good
5:Java in Practice: Exceptional Coding
6:Lego PalmPilot
7:XML and Java on the Menu
8:The Top 10 Intranet Design Mistakes
9:Servlet 2.3 API Features Exposed
10:JSP, Servlet and so on ...

Product Releases
1:JspExplorer
2:Java Web Start
3:Collection of Commercial Tag Libraries
4:New Tags at Jakarta Taglibs

Main Topic 
1:An Introduction to Struts

Like this newsletter? Tell a friend about the JSP Buzz!

================================================================
              THE LATEST NEWS
================================================================

1) Beta Release of Java 1.4 (3.16.2001)
The beta release of Java 1.4 should be out within the month. This is 
a nice review of what to expect. Hopefully, the production release of 
Java 1.4 (now known as J2SE - Java 2 Standard Edition 1.4) will be 
released in the fall of 2001.

2) Macromedia Completes Allaire Merger (3.23.2001) 
The combination of JSP, Cold Fusion, Flash, JRun and Kawa makes for 
very interesting possibilities in the future.  It's worth keeping half-
an-eye on developments over the next two years.

3) Microsoft Vexed by Falsified Certs (3.23.2001)
VeriSign issued certificates for Microsoft to non-Microsoft con artists.
While not a good thing, this serves as a reminder that nothing is secure 
on the Internet. Security is never a reality but rather a state of mind. 

================================================================
                   Rambles by Casey Kochmer
================================================================

*********************** JavaScript Debugging ************************* 

What a fun week. I spent most of the week building specialized JavaScript
functions to expand the DHTML Kit menu for a project. While the coding 
was fun, the debugging was more like torture.  In JavaScript, the quick 
application of an alert box is usually all that's needed to solve a 
problem.  However, at times an alert box can interrupt the logic to the 
point that the results are no longer valid.  I found an extremely neat 
solution to this using the innerHTML call instead of the alert box! 
The innerHTML command replaces the contents of an element on the page. 
It works in Explorer, Netscape 6 and Mozilla! The following example code 
replaces an alert box:   

var ack = document.getElementById("Test");
ack.innerHTML = "
X:" + l_pageX + " Y:" + l_pageY + ack.innerHTML In effect, I was using this code to track positions of events, but you could vary it for any debugging need. The actual data is written out to within a "div" element with the id of "Test" within the HTML page. This appends the test information straight to the HTML page itself! In this case the data is appended so new data would always appear at the top. This is kewl as the HTML page is self updating to reflect the debugging test values in real time. No more annoying alert boxes to close off every few seconds! It is also neat to note the possibility to append the data to any element on the page. In this case a "div" element was used to make the HTML code clean. An example page has been set up to demonstrate this technique at:
Debug Test Page In the next month or two I might make a debugging widget for the DHTML Kit which uses this technique. ******************* Some More on XML and JSP Design ******************* I had a fun email conversation with one reader about using XML within a JSP project. As a result, I will either write up the next main topic on the subject or possibly start a series of articles. I am curious to hear from others on the subject. I have been using XML in two manners, for internal data stores and for generating reports. The third important XML use is for inter-application communication. If you are interested in sharing your XML experiences I would love to hear about them. I am especially interested in hearing about unexpected uses of XML. As an example, I always expected to use XML as internal datastores, but in using JDOM I find that I am replacing my custom built data objects based on ArrayLists with JDOM XML representations instead. The reason? It is easier to use the prebuilt JDOM access methods than to custom build my own access methods. Of course, I gain the side benefit of being able to easily serialize my data objects as XML data strings. However, it's the ease of using JDOM to access and store the data that is driving the change, not the XML format itself. I expected the format(XML) and not the tool(JDOM)to drive the change in the way I do business. In retrospect it makes sense, since now the advantage comes from the fact that my customized data objects use the same interface (JDOM) for accessing data. This makes both maintenance and building new data objects easier. So if you have similar stories or surprising experiences, good or bad, I look forward to hearing from you. Thanks. Casey *********************** JSP in Other Languages *********************** While many technical sites are written in English, JSP has a very international flavor in its supporters. A previous Buzz listed several international Java user groups. This time we would like to provide a quick list of sites written in other languages. Chinese: China-Java Net 51 JSP/ French: WROX JSP Forum Japanese: JSP Tiny Samples Korean: JSP School Portuguese: JSP Brazil ********************* Internet Dust in the Wind ********************* In these times of financial chaos, it should be noted that small businesses are still being well served by the Internet. This shouldn't be surprising as the Internet, while huge, is all about being small. The idea of keeping everything simple and to basics applies to both business and coding models. The only trouble is, while large numbers of successful businesses are appearing on the Internet, the sensationalized huge or disastrous ones get our attention. As an example, a Swiss bank just announced they were pulling the plug on a 160 million dollar project. Over 100 million dollars and two years were spent on the Internet project. All that's left is Internet dust swirling around in the news stories. OK, I've been a small cog on billion dollar projects before, but those experiences have only reinforced the idea of using small projects as a means to build successful larger products and services. Just as a thought experiment, here is the high level approach I would propose. I expect the Swiss project should have been approached as a collection of smaller projects -- probably about 40 projects for the total 160 million dollar figure. While 4-10 million dollars per sub project is still large, it is more manageable. These sub projects in my mind would consist of several key core open source projects to build common components. Then a few key database projects would ensue to build the basic data structures. Once these efforts were at the beta phase, the next series of projects would be initiated. A few teams are needed which specialize in certain repeatable processes (where the construction process is repeatable, not the actual product) such as reporting and other standard processes. These teams would assist the other projects which are building the interfaces. Then of course you need a project to maintain the collection of projects. Possibly one sub management project would be needed for every six or so code projects. Finally, the timeline would need to be expanded. This approach would get parts of the system to market sooner, but it would also take a little longer to assemble the final total picture. However, in this design model, the project is never truly finished as success drives new releases and continued work in the future. Is this cheap? No. Extra time always has a price. However, failure is more expensive. Would this work? Yes. This thought experiment really wasn't a thought experiment as much as an examination of the process used for several successful large projects. After all, variations of this process were used to generate products and specifications such as Java, XML, Apache, etc. It works -- it just isn't the model used by the much of the corporate business world. This business model is more geologic in nature, but much more powerful in the end run. Lesson learned? While many factors are critical for success, keeping things small is critical in building for the web. The trick is to keep all the small pieces connected as the overall structure grows in size. Oh well.. Any large companies interested in a plan for distributed dynamic small project implementation (DDSPI)? Hmm, I better stay with my small projects. ================================================================ Links of Interest ================================================================ [Help] WebJava Advanced List Serv This is a little known list serv at Sun for advanced Java Web topics. If you are finding the normal JSP list Serv to be too basic then sign up for this list serv. Also, for questions which are based on the underlying servlets, check out the servlet list serv. [Article] Java Web Applications (Tomcat) (3.15.2001 James Goodwill) This first in a series of articles about using Tomcat gives a basic understanding of web applications. Only for new JSP programmers. [Fun] Anti-Mental Domination Devices This site just leaves me laughing. I suppose in a day and age of mind control wars this was bound to happen. This device just might make you immune to the massive marketing forces which are trying to dominate your spending dollar. Then again, maybe not. However, at the very least it would be a fashion statement. A special thanks to Amanda who found this link for me! [Article] Make Bad Code Good (3.23.2001 Dr. John Farrell) Refactoring has become a popular term lately. It can be a good way to help maintain and improve your code. This is a review on how to use refactoring to fix bad and older code you have inherited. I do recommend refactoring. It is a technique I have used for a good portion of my career and the methods are sound. [Article] Java in Practice: Exceptional Coding (3.2001 Ethan Henry) This discusses the proper use of Java exceptions. If you are unsure about the details in error handling in Java then this article is worth your time. [Lego] Lego PalmPilot Well this takes modular to whole new dimensions. It's a palm pilot, it's a lego kit -- no it's both! Hmmm, now how to get JSP installed on it ... ?! This link is dedicated to Bonnie. [Article] XML and Java on the Menu (3.25.2001 Dan Wahlin) Menus, menus everywhere! DHTML menus are getting more popular. When we started JSPInsider.com we were one of the few to use one. Now, while still uncommon, it isn't a surprise to see one anymore. This article reviews how to build a XML driven JSP menu. [Article] The Top 10 Intranet Design Mistakes (3.2001 Vincent Flanders) Vincent writes about the common problems found in intranet-based applications. This is a fun read. [Article] Servlet 2.3 API Features Exposed (3.22.2001 Stephanie Fesler) This article reviews the proposed final draft of the Servlet 2.3 specifications. A similar link was included in the Buzz two issues ago, but this article is included now as it is very nicely written. [Tutorial] JSP, Servlet and so on ... (CAFV) A JSP Tutorial. It appears that the authors are looking for contributors to help. So if you are interested check it out. ================================================================ Product Releases ================================================================ [JSP] JSP Explorer An interesting tool, whose main goal is to embed Java and JSP scripts within a Web document, then have JSP Explorer execute and display the results of execution of the code snippet. The author proposes being able to create your own Javadocs with working examples embedded within the Javadoc. Neat idea. [Java] Java Web Start (03.14.2001) This is a application deployment technology. With this tool it is possible to launch full-featured applications with a single click from a Web browser. It simplifies the installation of the Java program and gives the ability to use the Web to distribute and maintain client-side applications. From a JSP point-of-view this is important as users demand more traditional client-side features (such as advanced printing) be incorporated in server-side applications. This tools helps make this possible by providing a simple interface to deliver the client-side piece to the end user. [JSP Tags] Collection of Tag Libraries A collection of JSP Tag Libraries. [JSP Tags] New Tags at Jakarta Taglibs (03.2001) JDBC Taglib has tags for SQL database operations. The Scrape tag library can scrape or extract content from Web documents and display the content in JSP. ================================================================ MAIN TOPIC by Casey Kochmer ================================================================ ********************** An Introduction to Struts ********************** Within the JSP community several extremely important projects are currently being developed to the benefit of all JSP programmers. One project is called Struts and it is an open source framework built to simplify building a web application. The goal of this topic is to give an initial introduction to using Struts. (Experienced Model II programmers will want to skip this article.) Having a well tested framework for a project can be critical for long term success. A framework will give a project: - A standard approach which can be documented to make long term maintenance easier. - Modular code that has been tested and allows for quick reuse. - A central place to store reusable logic. Example: A single JavaBean to control security access. - Logical processing control. Example: All of the JSP pages automatically using the same security logic. Java is an object oriented language which lends itself to building reusable components. Components are great for single tasks, but most processes span multiple tasks. This introduces the need to glue together objects to handle a process. Different projects may also use the same processes, creating another opportunity to reuse methods. A framework performs both of these tasks. It allows a programmer to stitch objects together to handle a process and it is generic enough to allow for the reuse of the code in many different projects. In a sense, a framework is a large pseudo object geared towards easy generation of a project's output. Two common approaches are used to put together a framework -- Model I and Model II architectures. This article examines Struts which is based upon the Model II system. The Struts documentation gives an excellent overview on the details of Model II. If you are curious about how a Model II framework works, then the introduction from this documentation is highly recommended reading. Struts has many benefits over other frameworks, including: - It is open source, with the support of Sun and many talented programmers. - It is built with the internationalization features of Java to increase flexibility across languages. - It enjoys a large degree of community support. Struts is quickly becoming a defacto standard for a JSP implementation of a Model II framework. - It is a generic system reusable for many different projects. - It comes packaged with a healthy collection of tag libraries. I recommend using Struts over starting a new Model II framework. Building a framework from the roots requires both plenty of work and testing. In using Struts an immediate gain in productivity is achieved since the code has been built and tested by large numbers of JSP programmers. As Struts is open source, a project is free to expand and modify Struts to meet its requirements. Also, as Struts is generic, this provides a solid baseline in starting a project. A custom built framework will tend to support a particular project making it harder to reuse across different projects. The first step in using Struts is to download and install it. http://jakarta.apache.org/struts/installation.html For the new user this page can seem to be a bit much. However, the information is presented well and very important. The installation page really does help cover all the different options and variations depending on the JSP container used on a project. Installing Struts is both easy and a joy. The reason? The whole system is packaged as a set of WAR files. This pretty much means dropping the WAR files into a JSP container and then sitting back to watch the container do all the work of installation. (In Tomcat, simply drop the WAR files to the webapps directory and then restart Tomcat). A few additional steps are required to make sure your system can run Struts. For example, Struts requires having Java 1.2 and both JAXP (Java API for XML Parsing) and an XML parser installed within the system. The readme file explains everything and it is a simple matter. Once Struts is installed the layout comes as a pleasant surprise. Struts installs itself as a set of 6 Web applications. This partitioning is extremely useful and logical. You will find the following Web applications included within Struts: struts-documentation This web application contains the entire Struts documentation including the JavaDocs. The documentation is of excellent quality and very complete in content. struts-blank The starting application is for you to rename and start your own Struts application. To get started you rename the struts-blank.war to the name for your application. Then let your container auto-deploy it. Finally, edit the blank configuration files as needed. struts-example This is the main example mail reader application. struts-template This example Struts application shows how to use JSP templates to encapsulate webpage layout. struts-test An application for developers to test Struts. struts-upload An example Struts application showing how to use the HTML-based form constructor tags. The next step is to begin using Struts but I am going to leave that for the larger and more complete Struts article Jayson and I are currently writing. The Struts article will posted next week on the site. Struts can be found at the following link: http://jakarta.apache.org/struts/index.html ================================================================ SUBSCRIPTION ================================================================ You may unsubscribe from or subscribe to this newsletter by going to: http://www.jspinsider.com/jspbuzz/index.view

Browse all of the JSP Insider source-code.

Questions or comments? Contact support@jspinsider.com.