What's new
Follow me
About me


(www.visiti.no) I work for a Norwegian IT consultancy company called Visiti. The company was established the 1st of January 2009, with Software Innovation ASA as the sole owner. The company numbers 46 consultants within the fields of consultancy, system development and project management.
Visiti AS' goal is to be a renowned provider of IT consultants, primarily aimed at the banking, insurance and public sector, but also other selected businesses where IT is a critical success factor. Visiti AS delivers services and solutions based on both Microsoft and Java technology.
 

I lead the company's Java division, and is also out in the field. Doing some real work, getting my hands dirty.

  

 

 

Sunday
28Jun

Using Yahoo Pipes to keep everyone up to date

Yahoo pipes is a tool you can use to aggregate, manipulate, and mashup content from around the web. With the graphical user interface you can drag and drop inputs and operations into a designer, and connect them graphically. 

The output of the pipe can be read as RSS, JSON, KML and other formats as well.

One of the simplest yet  powerful uses of it, is to combine multiple RSS feeds into one.

I am now using pipes to...

  • Combine news from InfoQ, TSS, The Aquarium (Sun Glass fish Blog), Ed Burns's blog etc. etc etc. The blogs get piped into a  "recommended to read Feed"  that tmy collegues can use to keep updated. I download this feed to the Nokia E71 every hour automatically. That way, I always have fresh news to read if I have some spare time.    
  • Combine blogs written by my colleagues, both personal and work-related to encourage sharing of knowledge.  This also promotes the blogs and motivates everyone to contribute more.

 This is only scratching the surface. The Pipes Engine can read CSV files over HTTP, query Google & Flickr, sort, filter and much much more.

Using Yahoo piles in a cool way? Don't hesitate to leave a comment. 

Bookmark and Share
Saturday
27Jun

Getting started with JavaFX (in 30 minutes)

After hearing a lot of buzz about JavaFX, (and the upcoming "designer tool" demoed at Java One, scheduled for Q3/Q4), I decided to get my hands dirty with JavaFX. This is not a tutorial on JavaFX but rather references, and a summary of the experience of getting started.

 

 What is JavaFX?
According to the "all knowing Wikipedia"; "JavaFX is a software platform for creating and delivering rich Internet applications that can run across wide variety of connected devices. The current release (JavaFX 1.2, June 2009) enables building applications for desktop, browser and mobile phones. TV set-top boxes, gaming consoles, Blu-ray players and other platforms are planned."
JavaFX is not an API for GUI development, but rather a platform that uses a declarative programming language called JavaFX Script.
To have a quick view of the possibilities, take a look at the samples on javafx.com

Getting started with Eclipse
Sun has a "getting started" tutorial that looks okay over at javafx.com. It's worth noticing that there s no mention of how to get started with Eclipse (of course). I've heard a lot of praise of Netbeans lately, but learning something new, and a new IDE at the same time is not what I wanted.
I started my adventure and downloaded the 45 MB JavaFX SDK, at the same time updating my Eclipse 3.5 with a JavaFX Feature. This feature will among other things enable you to create a new "JavaFX Project from the "new Project" menu.

... A Small problem, my bad
A minor setback occurred during my first attempt to create a JavaFX project from the "new project" menu. I got the error message;”The JavaFX SDK location was not specified". This is because I am impatient, and installed the JavaFX plug-in before the JavaFX SDK. If this happens, it's just a matter of selecting the window/preferences dialog and select "class path variables" under "build path". There should be a JAVAFX_HOME class path variable pointing to the directory where the JavaFX SDK was installed.

And the first project
Creating a JavaFX project is easy. Just select create new project from the menu, and select "JavaFX Project". After that you can create new Java FX scripts, either empty, or have some example "hello world" like scripts to start playing with.

Conclusion
I was happy to see that JavaFX works with the latest eclipse. The only hiccup was a fault of my own. It's very easy to get started with JavaFX development, probably easier with Netbeans, as you can download both the IDE and SDK as a bundle. I was definitely up and running with the platform in under 30 minutes.

 References

 

 

Saturday
30May

HttpOnly cookies in the Servlet 3.0 Specification

If a web application is voulnerable to XSS attacks, your cookies can easily get in the wrong hands. One of the more popular targets for XSS attracks is of course your session cookie. In wrong hands this  cookie can enable an attacker to impersonate you, get access to persoal information or even your bank account.

Back in  2002 Microsoft implemented a mechanism called "HttpOnly Cookies" in their Internet Explorer 6 SP1". There is no magic involved; just an extra flag in the Set-Cookie response header. If the browser implements this, an attempt to read the cookie from a client side script will return an empty string.

Nowdays most servers and clients protects the session cookie this way; even though Ajax and the XMLHttpRequest object is lurking in the shadows. A snake in paradise but also a different story!

A new thing in the upcoming Servlet 3.0 specification is the support for HttpOnly custom cookies.

The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.Cookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.

In the new servlet specfication, the Cookie class has the following methods;

void setHttpOnly(boolean isHttpOnly)
boolean isHttpOnly()

Great news for security aware web developers!

 

 

Tuesday
13Mar

About Eclipse and Tekken

Eclipse and Tekken

The keyboard shortcuts in eclipse are a bit like advanced Tekken combat moves, for those who aren't into computer games; Tekken is a very good fighting game for the Sony Play Station consoles. A lot of the cool moves can only be made using insane combinations of the controller buttons, in the right sequence. In that sense, Eclipse and the computer game has a lot in common.

So... I'm using Eclipse for the moment, and have after a long period of swearing started to adapt a way of working that is similar to what I'm used to with IntelliJ. Here are a few painkillers for other Eclipse users that are used to IntelliJ. I guess most of this will be "old news" to experienced Eclipse users, but who knows. Why might pick up a trick or two.

Before starting I have to say that I try to learn keyboard shortcuts for everything I do. Other people prefer clicking around in the interface and I respect that. However, working with mostly the keyboard has some advantages; It's faster, It's better for your health and it's faster (did I mention that?)

Even after a months of using Eclipse, I still get confused on what shortcuts that are available through CTRL+SHIFT and what is through ALT+SHIFT. A good way to remember what is what is to think of the alt+shift shortcuts as "menu shortcuts". To Illustrate; Pressing Alt+shift+s gives you about the same options as pressing "source" on the menu. The CTRL+SHIFT shortcurs are more often helper dialogues like Open resource (CTRL+SHIFT+R) or open type. (CTRL+SHIFT+T)

Anyhow; here's a compilation of my most used keyboard shortcuts for eclipse. If you use these in combination, you can probably put the mouse away entirely.

Ctrl+M (Maximise)

I try to do as much work as possible with the source code window maximised. I try to use the "Navigator", and "Package Explorer" windows as little as possible, as I have found no way to switch to them with focus, without using the mouse.

Ctrl+F7 (Switch views)

In IntelliJ U can easily hide and show windows like the project navigator using the ALT key and number in combination, when you want the window to go away, you can press the same key, or escape.

Using the Ctrl+F7 and Ctrl+M (see previous) in combination makes navigating the different windows a bit easier. This shortcut lets you switch between the editor, navigator, console and all other views. I use it a lot to quickly go to the editor and almost always follow up with a CTRL+M, to use the entire screen area for code editing.

Ctrl + . (Next problem)

This navigates you to the next "problem" (red or yellow marker in the sidebar).

Ctrl+Shift+T (Find Type)

Finding a class in the package explorer or navigator can be like finding the famous needle in the haystack. It is often faster to hit this combo, and start typing the name of your class.

The good news is that wildcards and camel-back searching works like a dream.

Ctrl+Shift+R (Find Resource)

Same as above, only for resources that is not java classes. (JSP files ,properties etc. )

Alt+Shift+T (Refactor)

This shortcut is pretty neat as it pops up all refactoring options, given the context of the cursor position. The action you want to take is available in only one more keystroke. In full "Tekken* style" the shortcut key for "rename" is the key 'n', instead of using for example 'r' (that is unused). Don't ask me why.

Ctrl+F6 (Open files)

This is probably my single most used Eclipse shortcut. It pops up a list of all the recent files you have edited. An annoying "feature" of this key is that the CTRL key has to be pressed while doing a selection, or at least for a period of time for the window to "stick". If you briefly press Ctrl+F6, you get your last window. The design idea is probably that you often swap between the two most recent files.

I always use the combo "alt+right/left key" for that, so for me this extra "intelligence" is just annoying.

Alt+Right and left Arrows

The alt key in combination with the left and right arrow keys can be used as a "back" and "forward" in the file history.

F3 (Go to declaration) and "Ctrl clicking"

The entire source code can be navigated as a hyperlinked system. If the cursor is over a class name and you press F3, you immediately go to the declaration of that class.. Pressing F3 while the cursor is over a variable takes you to the declaration of that variable.

Similar navigation can be done by holding down the ctrl key and moving the mouse around. When the mouse pointer is hovering over a class name or variable, the name of the class or variable turns into a clickable hyperlink.

other usefull shortcuts that you're probably used to from IntelliJ

Ctrl+Shift+O (Optimize Imports)

This is one of many features that IntelliJ has implemented a bit smoother than Eclipse.

In general, the "Auto import" feature doesn't work to well if your code has compilation errors. This can be impractical if you let's for example say you want to copy / paste a block into your code from somewhere, and get a lot of "red markers" in your code as a result of the unknown classes.

In Eclipse you should avoid typing entire class names, it's better to type half way through and ctri+space to auto complete. This is because it imples an automatic import.

Ctrl+Shift+F (Format code)

This key combo formats your code according to default of project specific format.

Alt+Shift+X, T (Run as unit test)

This is one of many Tekken moves in Eclipse. Press Alt+shift+X after a while, a hint-box should appear with your choices. Press T to run the current class as a unit test . A disadvantage of using this shortcut is that the class currently in the editor has to be the unit test. This shortcut is best used in combination with the CTRL+F11 shortcut explained later.

Ctrl+F11 (Run last launch config)

If you run your unit test once using alt+shift+X (something that can and will break your fingers over time) there is no need to press the same combo again. Just use Ctrl+F11 to re-execute your last "run" or "debug" configuration.

Alt+Shift+Z

The nifty surround with functionality, also the home of the automatic collection iterator shortcut.

Alt+Shift+S (source)

Here you'll find shortcuts to all the nifty things like implement/override methods, generate getters/setters etc.

Ctrl+F8

Working with perspectives is important in eclipse. The whole editor changes it's window layout when working in debug mode. The Ctri+F8 shortcut enables you to switch back to java view (where I usually work) after a debugging session.

Ctrl + T

View Implementation/type hierarchy. If your editor is showing an interface, and you want to know all available implementations, this shortcut is handy. It also works if your cursor is located over an interface declaration.

Monday
06Nov

Working with JSF & MyFaces ; java.lang.IllegalStateException: Client-id : xxx is duplicated in the faces tree.

If you're working with JSF using Myfaces nad Tomahawk, and you are getting a stacktrace like this, you have probably just changed the internal structure of your JSP page. For some strange reason, that doesn't work too well in all cases.

What you need to do, is to make sure a new browser session is started, and access the page again.

java.lang.IllegalStateException: Client-id : xxx is duplicated in the faces tree. Component : _idJsp0:minus, path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /cars/default/jsp/agreement/bets/doors/viewd........