Wednesday, October 31, 2012

Servlet 3.0 and HTML 5 File Upload Servlet Example

Someone asked how simple is it to create a servlet using 3.0 technology which could upload a file. It took me about 5 minutes to do using NetBeans 7.2, and another 10 minutes to tweak for the file name. I hope that this proves how quick and easy it is to do. The code is also very readable.

Here is the code for my servlet, and form:

Tuesday, October 30, 2012

NetBeans 7.2.x Tip of the Day: Sharing PMD Configuration Files

I use the PMD plugin for NetBeans 7.2 for my development. If you are not using it, you should consider it. The plugin uses the ruleset from PMD project for static code analysis. Members of my team asked which rules I use when I evaluate their code so that they can handle it before I look at their code. I thought it would be as simple as exporting it, but that was not the case.

I filed an enhancement request for the feature: Export PMD Default Configuration Ruleset. Until it is added as a feature, here is how to pass your selected ruleset along.

The file that contains the rules which I am using is called The file is located in a couple of different places depending on if you are using Windows, or Mac OS X.

On Mac OS X it is located:

/Users/{USER_HOME}/Library/Application Support/NetBeans/7.2.1/config/Preferences
On Windows it is located:

I hope that helps if you need to share your rules.

Wednesday, October 24, 2012

JSF 2.x Tip of the Day: Creating RichFaces <a4j:commandLink/> Programmatically

As soon as I posted the previous blogpost Java Evangelist John Yeary's Blog: JSF 2.x Tip of the Day: Programmatic <h:commandLink/> I got a request for how to do it with RichFaces. The process is almost the same.

Here is an example for creating <a4j:commandLink/>
This example creates one for a table sorter on a RichFaces data table.

JSF 2.x Tip of the Day: Programmatic <h:commandLink/>

The JSF Tip of the Day is an amalgamation of a couple of tips: JSF 2.x Tip of the Day: Programmatically Creating EL ValueExpression and JSF 2.x Tip of the Day: Programmatically Creating EL MethodExpression which are combined with this tip.

In this tip we will create a <h:commandLink/> programmatically. The code from the previous tips noted, are used to create the component.

The component is bound using the following:

Article: How to get (almost) everything you ever wanted in one (not very) easy step

I finished reading the article How to get (almost) everything you ever wanted in one (not very) easy step by Richard Kennard in SD Times magazine. At first I thought it was going to go in a direction that I thought would be helpful for most developers who want to get involved in open source projects, or just become more involved in their respective development communities. My hope was quickly dashed. Don't get me wrong, the article is good, but most folks will not be able to take this approach. 

Richard's approach is to find something that you can turn in to a doctoral thesis, and work on your Ph.D. The article then covers how Richard did this himself.  Richard's passion is a project called Metawidget. This is a really cool technology. In fact it was so cool, that as part of the JavaOne paper selection committee I strongly recommended it. The committee agreed, and Richard gave a talk about it at JavaOne a couple of years ago.

I like Richard's passion about putting in the extra mile to get something accomplished for you, and the community. I just want to make sure that people don't get lost in the idea of a Ph.D. as a minimum level of commitment.

I have an email from Ed Burns the specification lead for JSF. He is asking for assistance with Javadoc updates. This is for JSR-344 JSF 2.2. This is an example of something where you can make a difference without a lot of personal time expense, and may provide the push to continue into bigger and better things.

I sure could use some help in bringing the new Javadoc 7 style to the generated portion of the JSF spec [1].  Can anyone from the Adopt-a-JSR program help me out here?  The task would be very hands-on, as the generated portion of the spec uses several different kinds of documents as its source inputs.
It can be something simple like this that would make the difference for a lot of people. 

Obviously, I like to blog which does not require a lot of time. Here is my secret about blogging... I forget things. My blog is a reminder of how to do things that I figure out, and need every so often. I know it may sound funny, but I often Google for something and get my own blog. Other times, I blog about articles which I find interesting. Like this article.

If you want to participate in any project, or technology just ask. The smart project owners/leads will find a place in their project for you. Eventually, you may lead your own project.

Saturday, October 20, 2012

Article: The JVM's Popularity

JVM and Modula3
I had kept an article from Dr. Dobbs Report called The JVM's Popularity by Eric J. Bruno with the intent of writing a quick blog post on it. This is the time I have to do it.

The article covers the Java VM versatility in a quick two page article. It describes some of the recent additions to the Java Language to support dynamic languages like JRuby called invokedynamic (JSR-292). This additional functionality allows dynamically typed languages to run without a performance penalty. The article explains this in a little more detail.

The article characterizes three categories of JVM languages: improve Java, port an existing language, and miscellaneous. Nothing too controversial. I did find one comment which I could not confirm though:

...NetRexx (the original JVM scripting language);
This was a surprising remark. I had never really heard of NetRexx running on the JVM until about a year ago when I was looking at a listing of JVM languages, and saw it. Does anyone know, and can confirm that it was the original JVM scripting language?

The last part of article refers to the upcoming release of Java 8 including the replacement Nashorn JS engine for Rhino.

A good quick article for an executive rundown on VM languages.

Article: Employers Hot On Application Developers

I just got through reading Employers Hot On Application Developers by Art Wittman in Information Week in the Practical Analysis series. It is a great read for anyone who is talking about career paths for students, and developers making career decisions.

I think one of the selling points is the money of course. The median income for staff developers is $95,000.00 USD. The other interesting information was that 7% of companies surveyed said that they would increase staffing of application developers by 21-30%, 11% were planning on staffing by more than 30%. I don't normally pay much attention to percentages without sampling data. However, it is still impressive.

It is a one page article and I recommend taking a peek at it. I found it interesting, and I hope you will too.

JSF 2.x Tip of the Day: Programmatically Creating EL MethodExpression

A common need is to create a MethodExpression for use in binding a JSF component action, or actionListener attributes to a value in the JSF/CDI managed beans.
Here is an example of how to use the method. In the example below I use both a ValueExpression and a MethodExpression for clarity. The MethodExpression is bound to a method called sort() in the IndexBean. Since this is bound to the action on the UICommandLink, it is expected that a String is returned which is used for determining navigation. Also note that an empty new Class[]{} array is passed as the expected parameter type.

Friday, October 19, 2012

JSF 2.x Tip of the Day: Programmatically Creating EL ValueExpression

A common need is to create a ValueExpression for use in binding a JSF component attribute to a value in the JSF/CDI managed beans.

This is a convenience method that I have created to create these expressions.
Here is an example of how to use it. In this example I bind the <h:commandLink/> value programmatically to the @ManagedBean called IndexBean value called columnHeader.

Sunday, October 07, 2012

Article: Even World of Warcraft is tracking you!

I just finished reading the Backspin article of the same name from the September 24th Network World Magazine. It is just another article that points out once again the lack of personal privacy and laws on the Internet.

Let me spare you a few cycles here, Blizzard Entertainment decided to use steganography to secretly (in this case the secrets out) encode trackable user information. This came to light earlier last month when screenshots were analyzed. The information includes account ID, time stamp, and IP address of the current realm. All of which can be used to stage an attack on the account owner. NICE!

The really bad thing is that the original information contained account ID which was equivalent to login information back in 2007. This has changed with upgrades, but warning to those with old accounts.

While I believe that most of us don't want to trust our government to monitor us to keep us safe. I do believe that they have a responsibility, as do we, to demand that laws which protect our privacy should have a minimal threshold. Let's call it a "Stupidity Factor" which says when you place personally identifiable information, or secondary information which combined with easily accessible information completes the picture, should make the exposer liable.

I am not one for lawsuits, but having something like a financial penalty which is a strong deterrent, and also offering civil liability make companies make "better" decisions. The general maxim for most companies has something like "maximizing shareholder value." Litigation and governmental fines, or restrictions in the ability operate are counter that proposition.

Essentially by holding these companies financially responsible is more likely to cause them to behave better, or at least give them pause.

Friday, October 05, 2012

JavaOne 2012: MICE and men

I attended a wonderful presentation on MICE (MASE) from the NATO Defence Programme as part of development on the NetBeans Platform. I was impressed with how NATO looked at NetBeans and understood what many of us already knew; NetBeans platform should be the first choice for doing Rich Client (Swing) development.

NATO was able to take advantage of common functionality provided by the platform like file handling, and user options, this left them to focus on the business of developing an air defense program. This is the way it development should be.

I had a great opportunity to talk with Angelo D' Agnano, one of the principal developers, at JavaOne. I was very excited to be able to give them a Duke's Choice Award at JavaOne. It was well deserved. The follow on talks just confirmed how cool it is.

Check out the The NetBeans Zone article on Dzone: Updated NATO Air Defence Solution Based on the NetBeans Platform

It will not disappoint.

Popular Posts