One Servlet Instance to Rule Them All...

I see a lot of people saying that: “there is only one instance of servlet per application”. Surely it gives you some information and knowing this will save you from a lot of strange, unexpected errors. However, the above statement is not very accurate and precise. It’s useful to know what is the actual contract between the web container and developer. Moreover, a lot of questions arise because of the multi-threading issues, so let me sum this up backing my words with Servlet 3....

April 30, 2012 · 2 min

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....

March 20, 2011 · 2 min

Accessing web application resources from different context

You can access the resources which are available for one servlet context from the other. Let’s say you have two web applications deployed (in the same Servlet container): /myApp1 /myApp2 Basically, if you’re in /myApp1 and you will execute the getServletContext() method on ServletRequest object, it will return the ServletContext for the application related with this ServletRequest object (in this case – /myApp1). With the ServletContext object you can execute getResource(-) or getResourceAsStream(-) to get access to the needed resource from within the /myapp1 application....

January 27, 2011 · 2 min