Friday, 31 May 2013

Applying Listeners to JSR Compliant Portlets

As per the JSR 286 Specification the following Listeners, which work with Servlet Requests, can be applied to requests targeted towards Portlets.
  • ServletContextListener 
  • ServletContextAttributeListener
  • HttpSessionActivationListener
  • HttpSessionAttributeListener
  • HttpSessionBindingListener
  • ServletRequestListener.

For this to work the Container needs to set a variable javax.portlet.lifecycle_phase.

Lets see an example.

Wednesday, 22 May 2013

Using Jenkin's to perform Build and Deploy for our custom Portlet : Setup Continuous Integration

In the last article we saw the steps to create a new JSR 286 Portlet from Scratch.

Now every time we make some change we need to build our project and then deploy it.
How cool it will be if these steps can be taken care of by click of a button.
Automation of such tasks can not just save time but also make us more efficient.

Below is a set of steps which can be used to setup Jenkins and then build Project using that. Its really simple. Jenkins is a Continuous Integration tool for automation of build, test and deploy.

Thursday, 16 May 2013

Create a simple JSR 286 Portlet - Part 2

In the last article we had completed the setup.


Now we will create our first JSR 286 Portlet.

1. In Eclipse navigate and go to File->new->other.





Create a simple JSR 286 Portlet using Maven, Eclipse IDE, MySql - Part 1

The Portlet we are going to create can be run on any Portal Server. I have used Liferay Community Edition since its available for free.

The tools we are going to use are:

1. Java V 1.5 and above.
2. Maven: It makes life so much easier.
3. Eclipse IDE
4. MySQL database
5. Liferay Community Edition bundled with Tomcat: Latest version is available at liferay.com

Monday, 6 May 2013

Comparing Servlets and Portlets Part 3 : Portlet deployment descriptor file


In the last article we saw how a RequestDispatcher works for both Servlets and Portlets.

Difference between a web and a portlet application.

A basic web application will have a web.xml file, Servlet classes and JSP's. The web.xml file helps to configure the Servlets which make the application. It helps a developer to define which URL's will be handled by which Servlets. How security will be applied to these URL's, session management etc.

Comparing Servlets and Portlets Part 2 : Using RequestDispatcher


In the last article we saw how we create a simple Servlet or a Portlet by implementing or extending appropriate interfaces and classes.

Lets continue to see what other differences are there.

RequestDispatcher

Unlike a Servlet where we can use either ServletRequest or ServletContext to get a RequestDispatcher object in a Portlet we can only use the PortletContext to do that. Just to refresh your memory RequestDispatcher can be used to forward the request to another Servlet or a JSP for further processing.

Friday, 3 May 2013

Comparing Servlets and Portlets Part 1 : Understanding the similarities and differences


People familiar with Servlet technology will be able to relate to Portlets. The concepts are more or less the same for both the technologies.

Lets do a quick walkthrough:

To start with the lets talk about their containers.

A container provides the environment in which the application can run. For running a servlet we will need a web application container like Tomcat.
On similar lines for a Portlet we need a Portlet Container. Most of the Portals today come with an inbuilt Portlet container to serve requests.