Portlet Tutorial – Hello Portlet 2.0 World

Here is an example of a portlet running inside a portal.

Create folder follow structure:

- c:\hello
      + web-inf
            ++ web.xml
            ++ portlet.xml
      + classes
            ++ HelloPortlet.java
            ++ HelloPortlet.class


public class HelloPortlet extends GenericPortlet {

  public void render(RenderRequest request, RenderResponse response)
                                 throws PortletException, IOException {

    response.getWriter().write("Hello Portlet 2.0 World");


<portlet-app xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd\"
               <title>Hello World Portlet</title>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

display name: hello in web.xml must same with war name when you create by jar command.

– compile class:     javac -classpath c:\lib\portletapi_20.jar   HelloPortlet.java
– create war file:    c:\hello> jar -cvf hello.war .

file hello.war will be create in hello folder.

Download hello.war: http://www.mediafire.com/?lnkjimckmfn
Download hello-src.zip: http://www.mediafire.com/?wwduzzzhdkd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s