Java EE 6 SCWCD Mock Exam

The mock exam has been moved to a separate application working on the OpenShift and is available at exam.piotrnowicki.com. This post will be still available because of the comments – at this point the exam simulator doesn’t have the commenting functionality so you can leave your opinion here. In time it’ll be modified and will allow to post comments directly next to the questions. If you’d like to get more information about the exam migration take a look at this post: New OCE WCD Exam Simulator. ...

March 27, 2011 · 1 min

Using Servlets 3.0 ServletContainerInitializer

Servlets 3.0 in Java EE 6, brings new interface called ServletContainerInitializer. The name is very self-explanatory, but the question is – how it’s different from the ServletContextListener? Well, technically, the ServletContainerInitializer is not a listener – it is an initializer and it’s executed before any servlet context will even be ready. You can use this initializer to do some programmatic servlet/filters/listeners addition (which is also possible in Servlets 3.0!). The ServletContainerInitializer.onStartup(Set<Class<?>> c, ServletContext ctx) can pass a set of classes which are a point of interest for the implementor (first argument). You can define such classes using @HandlesTypes annotation (also new for Servlets 3.0) which can be added to your ServletContainerInitializer implementation. For more information about the annotation, take a look at the linked javadocs. ...

March 20, 2011 · 2 min

Defining JSP version for Tag Files with implicit TLD

If you want to use new features of JSP >= 2.1 and EL, like deferred binding (the #{…} construction in EL), you’ll find that you cannot achieve it within a Tag File with implicit TLD generation. It is simply because the implicit TLD defines that the Tag File is using JSPs in version 2.0. How to solve it? There are two possible solutions: deliver an explicit TLD for your Tag Files, modify the implicit TLD form. Deliver an explicit TLD This solution is an obvious one – when you define the TLD you can set the version attribute for <taglib> element which defines the JSP version. But defining an explicit TLD when you deploy your Tag Files directly into the web container seems to be a bit of a redundancy. ...

February 20, 2011 · 2 min

JavaBeans -- getters with Boolean type

When you want to create a boolean property in a Java Bean (let’s name it visible), you most likely would want to use a boolean type variable and create accessors for it. Well, if you use a boolean primitive it is allowed to create a getter in one of two manners: public boolean getVisible() or public boolean isVisible() Notice that the second option is only allowed when your property is a boolean primitive. Therefore, when your property is a Boolean object, the getter should be in only one form: ...

January 13, 2011 · 1 min