Category Archives: J2EE

Why Web Developers Need JavaServer Faces

Short article at onjava.com entitled: Why Web Developers Need JavaServer Faces. Not much meat to it, but it sure the sparks are flying the comments section. If you don’t want to read it, here’s my data extraction:

· JSF prescribes an architecture for UI rendering to different clients.

· JSF provides rich client like event handling.

· JSF defines functionality for data conversion, validation, and localization.

That’s it… the entire support for why Web Developers need JSF. Pretty weak isn’t it?

Jakarta Latka

I have a peculiar interest in testing tools… I’ve mentioned JMeter (which is more of a stress testing tool) a couple times before, I just found a new one on the Jakarta site call Latka, which “… is a functional (end-to-end) testing tool. It is implemented in Java, and uses an XML syntax to define a series of HTTP (or HTTPS) requests and a set of validations used to verify that the request was processed correctly.

The cool thing about Latka is the non Java part… anyone that understands a little XML can create and/or edit an xml document that defines an ‘test’ and then run it using the Latka engine. So for instance, here at Mindseye our QA team is composed of invididuals with a small amount of programming experience. They could easily create a Lakta test using the xml syntax and then automate the testing of various applications using Latka. Still not convinced, here’s a sample test:

<?xml version=”1.0″ standalone=”no”?>
<!DOCTYPE suite PUBLIC “-//Apache Software Foundation/DTD Latka Test Suite 1.0/EN”
   “http://jakarta.apache.org/commons/latka/dtds/1.0/suite.dtd”>
<suite defaultHost=”http://www.mindseye.com” label=”mindseye”>
   <request path=”/whymindseye/default.cfm” label=”why you should choose mindseye” method=”get” secure=”false” followRedirects=”true”>
      <validate>
      <statusCode code=”200″ />
      <regexp pattern=”What drives landmark companies” />
      </validate>
   </request>
</suite>

Save this to a file and then type:

latka file:PATH_TO_FILE

from the command line. It should check that the page http://www.mindseye.com/whymindseye/default.cfm returns an HTTP status code 200 and that it contains the phrase “What drives landmark companies”.

Unfortunately, Latka doesn’t appear that anyone is working on it (at least since last July).

On a related note, I also found this Slashdot discussion on “Testing Products for Web Applications?“.

100 New Java Performance Tuning Tips

Java Performance Tuning author Jack Shirazi attended 8 J1 performance sessions and published a big bulleted list with 100 new insights gained from these talks, from trivial stuff like ‘use lazy loading’ to cool stuff like ‘Chose optimistic concurrency for CMPs with read-mostly access’ and ‘in servlets, set content length; for JSP pages, set UseOutputStreamSize’.” Read about here. [via theserverside.com]

Calling Java Constructors with ColdFusion

I mentioned yesterday that Sam posted some great code that lets you upload files to ColdFusion without using CFFILE. His code can be shortened considerably with the use of the init() method:

<cfscript>
fileAsString = “”;
fileReader = createObject(“java”, “java.io.FileReader”);
fileReader.init(form.upFile);
bufferedReader = createObject(“java”, “java.io.BufferedReader”);
bufferedReader.init(fileReader);
try {
   do {
      fileAsString = bufferedReader.readLine();
      processLine(fileAsString);
   } while (true);
} catch (coldfusion.runtime.UndefinedVariableException e) {
// this indicates end of file, ok to ignore error
}
</cfscript>

Basically, you use the CreateObject() function to get a Java object. At that point, you can call static methods on the object or you can use the init() method to call the constructor of the Java object, which I’ve done above, ie:

// get a FileReader object
fileReader = createObject(“java”, “java.io.FileReader”);
// call the FileReader object constructor
fileReader.init(form.upFile);

If you’re curious about this kind of stuff, you should check out the article on Java, ColdFusion MX and Lucene integration I wrote for the July issue of ColdFusion Developer’s Journal, due to hit the stands anytime now.