Saturday, April 4, 2009

JSR 168, 286 Portlets & Portal Interview Questions

What is a portal ?

A portal can be best described as a web site that acts as a "point of entry" or a gate to a larger system. While it seems pretty difficult to define a portal in the strictest sense, these are some of the common 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.
  • 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.

What is a JSR 168 Portlet ?

Prior to JSR 168, almost all portal platforms offered their own proprietary approach to create pluggable portal components. For example, IBM had IBM portlets, Sun(iPlanet) had Providers, SAP had iViews and Plumtree had Gadgets.

JSR 168 aims to standardize these pluggable portal components so that they are independent of the actual portal server that they are written to. What this means is that one can migrate portlets seamlessly from one portal server to another without any code change.

What are the types of request in JSR 168 portlets?

Their are two types of request :-
1) RenderRequest
2) ActionRequest

What are the differences between portlets and servlets?

Essentially, Servlets provide content that normally takes up the whole page in a browser (unless you're using frames), and portlets provide content that is wrapped by a window. With portlets, you can have multiple portlets side by side with one another and each one can provide content and functionality that is different from the other. A portlet can provide the complete interaction for one type of application, while another portlet can provide content for another type of application. The portal can provide some house keeping functionality and secured single point of entry to all of the portlets on a page. As for the particulars (similarities/differences) between them, please continue reading.

Here are some similarities:

  • Servlets and portlets are web based components that utilize Java for their implementation
  • Portlets are managed by a portlet container similar to a servlet container
  • Both of these components generate content, which can be static or dynamic
  • Both portlets and servlets have a lifecycle that is controlled by the container
  • The client/server model is used for both servlets and portlets
  • The packaging and deployment are essentially the same
  • The manner in which the classes are loaded and the class loaders that perform the work are also the same
  • Lifecycle management is similar
  • The Request and Response semantics are also similar

Here are some differences:

  • Servlets can provide complete web pages, whereas portlets only provide fragments. These fragments are then aggregated to form a complete web page by the portal
  • Portlets aren?t allowed to generated HTML code that contains tags such as base, body, frame, frameset, head, html, or title. The iframe tag can be used with caution.
  • The user cannot access a portlet directly using a URL in the way that a servlet is accessed. Instead, the URL points to the page containing all of the portlets on one page
  • Communication between the web client and the portlets is performed through the portal
  • Portlets can be provided with buttons or controls to manipulate the portlets? window states or portlet modes
  • Multiple instances of a single portlet can be placed onto the same page
  • Portlets support persistent configuration and customization
  • Portlets also support user profile information
  • Portlets support two scopes within the session; application scope and portlet scope

There are several things that servlets are allowed to do, but portlets aren?t. These include the following:

  • Portlet aren?t allowed to set the character set encoding of the response
  • Portlet also aren?t allowed to set the HTTP headers on the response
  • Portlet cannot manipulate the URL of the client request to the portal

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.

Can I get the HttpServletRequest from a Portlet?

The PortletRequest object is supposed to give you everything you need i.e. parameters, attributes, dispatching, etc. As per the spec, you should not need the HttpServletRequest.

However, some portlet container implementations do provide some kind of hack to get hold of HttpServletRequest e.g. in Pluto you can cast the RenderRequest to HttpServletRequest. But, be aware that this behavior cannot be relied upon.

What's difference between PortletConfig.getInitParameter() and PortletContext.getInitParameter()?

Context-wide init-params share the same context space as Servlets and JSPs belonging to the same application and they are defined in the web.xml file. You can get them using PortletContext.getInitParameter() method.

Portlet-wide initialization parameters on the other hand belong in the portlet.xml file and you can get them using PortletConfig.getInitParameter() method.

What is a PortalSession Interface ?

User identification across many requests and transient information storage about the user is processed by PortletSession interace. One PortletSession is created per portlet application per client.

The PortletSession interface provides a way to identify a user across more than one request and to store transient information about that user.

The storing of information is defined in two scopes- APPLICATION_SCOPE and PORTLET_SCOPE.

APPLICATION_SCOPE: All the objects in the session are available to all portlets,servlets, JSPs of the same portlet application, by using APPLICATION_SCOPE.

PORTLET_SCOPE: All the objects in the session are available to the portlet during the requests for the same portlet window. The attributes persisted in the PORTLET_SCOPE are not protected from other web components.

What is a PortletContext Interface ?

The portlet view of the portlet container is defined by PortletContext. It allows the availability of resources to the portlet. Using this context, the portlet log can be accessed and URL references to resources can be obtained. There is always only one context per portlet application per JVM.

Is there any difference betweeb websphere and weblogic ?

Webpshere tends to focus more on integration, connectivity and web services. it has rich implementation of J2EE, better performance, more extensive integration and transaction management. In terms of trnsaction weblogic is having default transaction attribute as ’supports’, but websphere does not have any default transaction attribute.

How to implement JDBC-ODBC bridge driver (Type 1 ) in Websphere?

If you use JDBC type (I) driver you dont need to add any driver in websphere. you simply created DSN and use it locally, same we use java class, if you use Type(2) and Type(4) so first go to admin console then go to connection, then add driver there fill other info like conn. size, uname pass, max conn. and connect it to you applications.


What is the difference between application server and web server?

ApplicationServer: takes care of Security, Transaction, Multithreading, Resource pooling, load balancing, clustering, performence, highly availability, scalability, etc. Exposes business logic to client applications through various protocols, possibly including HTTP. Supports deployment of .war and .ear filesApplication server = webserver + EJB container.

Webserver: handles HTTP protocol. Receives HTTP request, it responds with an HTTP response.

Explain relationship betweeb the Servlet Container and Portlet Container?

The portlet container is an extension of the servlet container. As such, a portlet container
can be built on top of an existing servlet container or it may implement all the
functionality of a servlet container. Regardless of how a portlet container is implemented,
its runtime environment is assumed to support Servlet Specification 2.3

Explain portlet lifecycle?

A portlet is managed through a well defined life cycle that defines how it is loaded,
instantiated and initialized, how it handles requests from clients, and how it is taken out
of service. This life cycle of a portlet is expressed through the init, processAction,
render and destroy methods of the Portlet interface.




















12 comments:

  1. Good one. Thanks.

    ReplyDelete
  2. Hey friends more interview questions on portlet and portals refer http://www.commoninterviewquestions.org/portal-architect-interview-questions/

    ReplyDelete
  3. Very well done. Thanks for all the content.

    ReplyDelete
  4. Brajesh, Thanks for sharing
    Very informative and descriptive.

    ReplyDelete
  5. very informative, very much useful

    ReplyDelete
  6. Nice post..keep rocking

    ReplyDelete
  7. thank you brajesh ....i have question about portlet development using rad 7, that when i create basic portlet project, in the JSP's of this portlet the jsp tags are broken , why? and what is the solution

    ReplyDelete
  8. Really informative content.
    Thanks you so much

    ReplyDelete
  9. Thanks much Rajesh !!!!

    ReplyDelete
  10. very good. keep on writing these types of liferay IQ.
    Thanks

    ReplyDelete