Choose.. X Home Exams Certifications
 

Portal Technologies Interview Questions

1 . What is portal?

  • Portal is a configurable desktop for collection of applications, or A portal is a powerful Web site that gives users a single point of access to applications and information in a unified interface.
    A portal lets users view each application or Web page in its own window, called a portlet, and a single browser window can contain multiple portlets.
    For example, a portal page can contain portlets for logging in, searching, displaying news feeds, and managing appointments with a calendar application

2 . What are features of portals?

    • Content aggregation: Portals tend to aggregate content from multiple, disparate sources and provide one unified view of the same.
    • Personalization: This refers to the ability of the portal to tailor the content/services that it offers according to the user of the portal.This is the capability of web application to tailor it's behavior according to user characteristics.
    • Search: Most if not all portals, offer some form of searching of it's content and sometimes even content from external sources.
    • Single Sign On: Allows users to authenticate once to the portal and thereby allows access to many other systems without the need for re authentication.

3 . What is Portlet?

  • Portlets are pluggable user interface software components that are managed and displayed in a web portal. Portlets produce fragments of markup code that are aggregated into a portal.
    A portlet is a Web-based component that will process requests and generate dynamic content.
    The end-user would essentially see a portlet as being a specialized content area within a Web page that occupies a small window in the portal page.
    Depending on the content nature of the Web site providing the portlet you could use this area to receive different types of information such as travel information, business news, or even local weather.
    The portlet provides users with the capability to customize the content, appearance and position of the portlet.

4 . What are different Portlet standards? Explain difference?

  • JSR-168: The Java Portlet Specification V1.0 introduces the basic portlet programming model with:
    • two phases of action processing and rendering in order to support the Model-View-Controller pattern.
    • portlet modes, enabling the portal to advise the portlet what task it should perform and what content it should generate
    • window states, indicating the amount of portal page space that will be assigned to the content generated by the portlet
    • portlet data model, allowing the portlet to store view information in the render parameters, session related information in the portlet session and per user persistent data in the portlet preferences
    • a packaging format in order to group different portlets and other Java EE artifacts needed by these portlets into one portlet application which can be deployed on the portal server.
    • Portal development is a way to integrate the different web-based applications for supporting deliveries of information and services.
    JSR -286: JSR-286 is the Java Portlet specification v2.0 as developed under the JCP and created in alignment with the updated version 2.0 of WSRP. It was developed to improve on the short-comings on version 1.0 of the specification, JSR-168. Some of its major features include:
    • Inter-Portlet Communication through events and public render parameters
    • Serving dynamically generated resources directly through portlets
    • Serving AJAX or JSON data directly through portlets
    • Introduction of portlet filters and listeners

5 . What is the difference between servlet and portlets?

  • Portlets are part of JSR-168&286 standard that regulates portal containers and components.
    This is different standard from standards for web containers (and servlets).
    Though there are definitely strong parallels between these two standards they differ in containers, APIs, life cycle, configuration, deployment, etc.
    The main difference between portlet vs. servlet could be that while servlet always responds to single type of action - request, portlet (due to nature of its life cycle and stronger container bindings) has to respond to two types of actions: render and request.
    Similarities
    • Servlets and Portlets are web based components which use Java for their implementation.
    • Portlets are managed by a portlet container just like servlet is managed by servlet container.
    • Both static and dynamic content can be generated by Portlets and Servlets.
    • The life cycle of portlets and servlets is controlled by the container
    • The client/server model is used for both servlets and portlets
    • The packaging and deployment are essentially the same, WAR/EARs.
    Dissimilarities
    • Servlets can render complete web pages, whereas portlets renders html fragments. These fragments are aggregated by the portal into a complete web page.
    • The content type of JSR 168 portlets can be only cHTML, XHTML, WML. It does not support other content types.
    • Portlets are not allowed to generate HTML code that contains tags such as body, frame, frameset, head, html, or title.
    • A Portlet unlike a servlet doesn’t have URL attached to it so it cannot be accessed directly. Access is only through the portal page which holds the portlet.
    • Portlets can be provided with controls to manipulate its window states or portlet modes.
    • Multiple instances of a single portlet can be placed onto the same page.
    • Portlets support persistent configuration and customization, profile information.
    • Portlets can have two types of request viz. render request and action request.
    • Portlets have two scopes within session; application scope for communication across portlets and portlet scope for intra portlet communication.
    • Portlet cannot set the character set encoding of the response nor can it set the HTTP response headers.
    • Portlets doesn’t have access to request URL. So it cannot access the query parameters appended to the URL.
    • Portlets cannot set cookies.

6 . What is a portlet container ?

  • A portlet container runs portlets and provides them with the required runtime environment. A portlet container contains portlets and manages their lifecycle. It also provides persistent storage for portlet preferences.
    A portlet container receives requests from the portal to execute requests on the portlets hosted by it. A portlet container is not responsible for aggregating the content produced by the portlets. It is the responsibility of the portal to handle the aggregation.

7 . What is portlet lifecycle?

    • The init(PortletConfig config) is called once, immediately after a new portlet instance is created. It can be used to perform startup tasks and is akin to a servlets init method. PortletConfig represents read-only configuration data, specified in a portlet's descriptor file, portlet.xml(more on this file later). For example, PortletConfig provides access to initialization parameters.
    • The processAction(ActionRequest request, ActionResponse response) method is called in response to a user action such as clicking a hyperlink or submitting a form. In this method, a portlet may invoke business logic components, such as JavaBeans, to accomplish its goal. The ActionRequest and ActionResponse Interfaces are subinterfaces of PortletRequest and PortalRequest. In processAction, a portlet may modify its own state as well as persistent information about a portlet.
    • The render(RenderRequest request, RenderResponse response) method follows processAction in the chain of lifecycle methods. Render generates the markup that will be made accessible to the portal user. RenderRequest and RenderResponse methods, also subinterfaces of PortletRequest and PortletResponse, are available during the rendering of a portlet. The way in which the render method generates output may depend on the portlet's current state.
    • The destroy() method is the last lifecycle method, called just before a portlet is garbage collected and provides a last chance to free up portlet resources.

8 . What is event in portlets?

  • An event is a life cycle operation that occurs before the rendering phase. Events can be described as a loosely coupled, brokered means of communication between portlets.
    Events allow portlets to respond on actions or state changes not directly related to an interaction of the user with the portlet.
    A portlet can declare events in its deployment descriptor by using the event-definition element in the portlet application section.
    In the portlet section, each portlet specifies the events it would like to publish through the supported-publishing-event element and the events it would like to process through the supported-processing-event element.

9 . What is portlet config?

  • The PortletConfig object provides the portlet object with information to be used during initialization.
    It also provides access to the portlet context, default event namespace, public render parameter names, and the resource bundle that provides title-bar resources.

10 . What are portlet modes?

  • A portlet mode indicates the function a portlet is performing in the render method.
    A portlet mode advises the portlet what task it should perform and what content it should generate.
    When invoking a portlet, the portlet container provides the current portlet mode to the portlet. Portlets can programmatically change their portlet mode when processing an action request.
    The Portlet Specification defines three portlet modes, VIEW, EDIT, and HELP. The PortletMode class defines constants for these portlet modes.
    The availability of the portlet modes, for a portlet, may be restricted to specific user roles by the portal.
    For example, anonymous users could be allowed to use the VIEW and HELP portlet modes but only authenticated users could use the EDIT portlet mode.
    Portlets must support the VIEW portlet mode.
    Portlets are not required to support the EDIT/HELP portlet mode

11 . What are portlet window states?

  • A window state is an indicator of the amount of portal page space that will be assigned to the content generated by a portlet via the render method.
    The Portlet Specification defines three window states, NORMAL, MAXIMIZED and MINIMIZED. The WindowState class defines constants for these window states.
    The NORMAL window state indicates that a portlet may be sharing the page with other portlets. It may also indicate that the target device has limited display capabilities. Therefore, a portlet should restrict the size of its rendered output in this window state.
    The MAXIMIZED window state is an indication that a portlet may be the only portlet being rendered in the portal page, or that the portlet has more space compared to other portlets in the portal page. A portlet may generate richer content when its window state is MAXIMIZED.
    When a portlet is in MINIMIZED window state, the portlet should only render minimal output or no output at all.

12 . What is the difference between customization and personalization?

  • The term "customization" is used to mean the rendering of portlet content based on users preferences or manipulating the portal layout based on the users security attributes.
    The term "personalization" is used to mean delivering portlet content based on a business rule or collaborative filtering.
    Customization centers around what resources (portlets and pages) you show the users based on their role. This is a core capability of Portal.
    There are tools provided that help administrators provision these resources. Typically, portlets allow users to specify what kind of information should display. For example, a weather portlet might be customized to show weather in the users home town.
    Personalization can deliver content to a user based on a profile and/or business rule, or determine characteristics of a user based on previous purchases, or pages viewed. Personalization then selects content that is appropriate for that profile.
    For example, if a person has a high salary range, personalization can be configured to retrieve information about premium products, the page is assembled with the proper information and the user sees his personalized page.
    Personalization includes a rules engine, a recommendation engine and a resource engine. Although a full install of Portal installs and configures personalization functions by default, there are additional databases to consider.
    To use personalization, you need content to display to your users. Therefore, personalization and content management go hand in hand. You will also need to understand where content is stored and how it is managed to optimize performance.

13 . What is Inter-portlet communication?

  • Passing of parameters from one portlet to other portlet is called interportlet communication.
    JSR-286 introduces two methods of Inter Portlet Communication:
    Shared render parameters: allows portlets to set params that can be read by other portlets. This rather simple mechanism will probably be enough for all but the most complex communication needs.
    Events: needed for complex scenarios. The main advantage of this second method is that it allows a fully decoupled communication. A portlet issues an event and doesn't have to care if there is anyone listening for it.
    Various vendors use different method of interportlet communication before JSR-286.

14 . What is portlet context?

  • The PortletContext interface defines a portlet’s view of the portlet application within which the portlet is running.
    Using the PortletContext object, a portlet can log events, obtain portlet application resources, application and portlet runtime options and set and store attributes that other portlets and servlets in the portlet application can access.
    If you need an object to be shared/used by all users in portal, stored the object in portletcontext attribute.

    The portlet context leverages most of its functionality from the servlet context of the portlet application. However, the context objects themselves may be different objects.
    The context-wide initialization parameters are the same as initialization parameters of the servlet context and the context attributes are shared with the servlet context.
    Therefore, they must be defined in the web application deployment descriptor (the web.xml file).The initialization parameters accessible through the PortletContext must be the same that are accessible through the ServletContext of the portlet application.

    Portlet context attributes can be set by both ways i.e programmatically or declaratively. If you choose declaratively way, context attributes can be declared in web.xml only, not in portlet.xml.
    Set the portletcontext attribute in web.xml
    
    
    <?xml version="1.0" encoding="UTF-8"?>
          <web-app id="WebApp_ID" version="2.5"
          xmlns="ttp://java.sun.com/xml/ns/javaee"
          xmlns:xsi="ttp://ww.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="ttp://java.sun.com/xml/ns/javaee
          ttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
          <display-name>PortletContext</display-name>
          <context-param>
          <param-name>Admin</param-name>
          <param-value>Admin</param-value>
          </context-param>
          <welcome-file-list>
                <welcome-file>index.html</welcome-file>
          </welcome-file-list>
    </web-app>
    
     public class PortletContext extends GenericPortlet {
    
        public static final String JSP_FOLDER    = "/_PortletContext/jsp/";
        public static final String VIEW_JSP      = "PortletContextView";        
    
        public void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException {
            // Set the MIME type for the render response
            response.setContentType(request.getResponseContentType());
            javax.portlet.PortletContext context=getPortletConfig().getPortletContext();
            Enumeration names=context.getInitParameterNames();
            while(names.hasMoreElements())
            {
                String parametername=(String)names.nextElement();
                String parametervalue=context.getInitParameter(parametername);
                System.out.println(parametername+ "="+parametervalue);
            }
            // Invoke the JSP to render
            PortletRequestDispatcher rd =
                    getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));
            rd.include(request,response);
        }
    
        private static String getJspFilePath(RenderRequest request,
                                                String jspFile) {
            String markup = request.getProperty("wps.markup");
            if( markup == null )
                        markup = getMarkup(request.getResponseContentType());
            return JSP_FOLDER + markup + "/" + jspFile + "." + getJspExtension(markup);
        }
    
        private static String getMarkup(String contentType) {
            if( "text/vnd.wap.wml".equals(contentType) )
                        return "wml";
        else
        return "html";
        }
    
        private static String getJspExtension(String markupName) {
            return "jsp";
        }
    
    }