Welcome!

Java IoT Authors: Elizabeth White, Yeshim Deniz, Liz McMillan, Pat Romanski, ManageEngine IT Matters

Related Topics: Java IoT

Java IoT: Article

Developing Web Portals in Jetspeed Using JSP

Simplify the process

A Web portal is an application that aggregates multiple Web applications on a single Web page. Popular examples of portals are My Yahoo (my.yahoo.com) and My MSN (my.msn.com). These portals allow users to aggregate multiple Web applications (like Stock Quote, News, and Weather). In addition these portals allow users to personalize and customize the presentation and content of the individual Web application. This means users may do both: change the color, style, and layout of the page, and specify the content - list of stocks in a Stock Quote application and categories of news in a News application.

The Java community has created a standard for developing portal applications; it's called the Portlet API. The individual Web applications described above are called portlets. In August 2003, Portlet API specification, JSR 168 (http://jcp.org/en/jsr/detail?id=168), completed the public review process. The goal of the specification effort is to "enable interoperability between portlets and portals by defining a set of APIs for Portal computing addressing the areas of aggregation, personalization, presentation and security." This allows portlets to be developed once and deployed on any Web portal that is compliant with the portlet standard.

This article will describe how to develop JSP portlet applications using Jetspeed. Jetspeed (http://jakarta.apache.org/jetspeed) is an open source project from the Apache Foundation that provides tools to build Web portal applications. Its current release, Jetspeed 1.4, provides a portlet-based implementation. Jetspeed 2.0 is currently under development for release in early 2004. This will be compliant with JSR 168 portlet standards and built on Apache's Pluto, which is a reference implementation of JSR 168 (http://jakarta.apache.org/pluto/).

This article demonstrates a method to develop JSP portlets with a declarative specification of server-side logic instead of server-side programming. This is in contrast to current methods of developing JSP portlets that involve a significant amount of server-side programming.

The Jetspeed application is available as a WAR file and may be downloaded from http://jakarta.apache.org/jetspeed/. The WAR file may be deployed in Tomcat 4.1, WebLogic, WebSphere, or other J2EE application servers. The tutorial at http:// jakarta.apache.org/jetspeed/tutorial/ is a good guide to getting started. It explains how to aggregate, personalize, customize, develop, and deploy new portlets, therefore it will not be repeated here. This article focuses on developing portlets using JSP. To illustrate how JSP applications are developed in Jetspeed, we'll use a simple User Profile example (this will be referred to as Portlet 1 in Figure 1), with the following functionalities:

  1. When a Web page with the User Profile portlet is loaded on the browser, the logged in user's address and phone number are displayed.
  2. User changes the information and clicks on Update. The changed values are updated in the database.
  3. The returned page displays the updated information. Standard Method for a JSP Portlet
Standard Method for a JSP Portlet
An implementation of the sample application in Jetspeed, using the traditional method, will consist of the following files (see Listings 1-3). (Listings 5-7 can be downloaded from www.sys-con.com/java/sourcec.cfm.)
  • profile.jsp: JSPPortlet requires that the name of the submit form element have this prefix: "eventSubmit_". The name after this prefix, for example, "doUpdate," is the method that is called in profileJSPActionClass.
  • profileJSPActionClass.java: The action class must contain two methods - buildNormalContext and a method called from the JSP page. The buildNormalContext() method is the last method called every time the portlet is displayed or refreshed. If ProfilePortlet is submitted, Jetspeed calls doUpdate() first and then calls buildNormalContext().
  • profile.xreg (the Jetspeed registry file): An XML file for registering a portlet, it specifies the type of portlet, JSPPortlet; the action class, indentJSPPortletAction, that will handle the submit event and deliver content to Jetspeed for rendering; and the startup parameters for the portlet.
Figure 2 shows the flow logic for four conditions in the action class:
  • When the portlet application is first loaded in a Web browser
  • When the portlet application issues a submit request that involves a database update
  • When the portlet application issues a submit request that involves getting data
  • When the page containing the portlet application is refreshed or another portlet application on the same page is submitted
A Jetspeed container typically contains several Portlet classes - JSPPortlet, RSSPortlet, IframePortlet, VelocityPortlet, etc. A JSPPortlet may be servicing several portlet applications - P1, P2, … Pn. When a Portlet is submitted from a browser, the Jetspeed container determines which portlet class will process the request. The portlet class then hands over the request to the action class of the appropriate application. For each portlet application, developers write an action class and several methods in the action class. The action class typically calls a business component or database to satisfy the request. The data returned by the business component is used to render the return JSP page of the portlet application that was submitted. Other portlet applications on the same page are returned from the cache.

In the traditional method of developing JSP portlets (see Figure 3), developers write action classes and methods that are request specific. For example, if Portlet 1 has five JSPs and each has two different submits, in a worst case scenario a developer would write 10 methods in Portlet 1's action class. Each portlet is typically configured to be processed by a different action class. Extending this analysis to four portlets with each requiring 10 methods would suggest that a developer would write 40 methods.

The issue with this approach is that for any reasonably sized Web portal, the collection of action classes and methods proliferates and becomes unmanageable.

Declarative Method for Creating a JSP Portlet
Faced with this problem, we have developed a broker class that provides a single action class, IndentJSPAction- Class, and a single action method, doSubmit(), to which all JSP pages are submitted (see Figure 4).

For brevity the broker class will be illustrated with an example in which action is limited to a database transaction. Two parameters are sent to the action class: actionType and actionName. actionType is "select" or "update" and actionName is the name of a request, whose purpose will become apparent soon. The broker action class calls Aspire, which is a declarative middle tier (www.indent.org/aspire.htm). Aspire is an open source J2EE program developed by coauthor Satya Komatineni. To download Aspire's JAR file and the source code of the examples go to www.indent.org/jetspeedDownload.htm.

In Figure 4 JSPPortlet forwards the request to a single class and single method in the broker. Action Class calls Aspire with a parameter aspireURL. Aspire reads the declarative definition for aspireURL and transacts with the database. The retrieved data is transformed to a hierarchical data set (HDS). The outgoing JSP page then uses HDS to create the display.

The broker is employed in simplifying the action class. The role of the action class is twofold. In the case where "actionType=select", the action class is responsible for retrieving data from a database as an HDS. The outbound JSP uses the HDS for display in the browser.

In the case where "actionType= update", the action class is responsible for modifying content in a database. Once the update takes place, the user can be redirected to an appropriate page. Separating the role of the action class into these two categories offers clarity in the design of portlets.

The broker class has prebuilt parts that can construct an HDS declaratively from a set of SQL statements. This means the action class can make use of these definitions to automatically generate the necessary data for a Web page. In case of an update, the broker class provides a declarative update pipeline of parts where multiple update SQLs or stored procedures are executed against a database transactionally. By coupling these two declarative facilities, a generic action class for the JSPPortlet has been developed that streamlines the process for developing Jetspeed portlet pages rapidly. For more information about HDS and Aspire see "Using Hierarchical Data Sets with Aspire and Tomcat," www.onjava.com/pub/a/onjava/2003/03/05/hds.html.

An implementation of the sample application in Jetspeed contains the following files, shown in Listings 4-7.

  • Aprofile.jsp: Uses Aspire and hierarchical datasets to get data for display. A hierarchical dataset is generated by Aspire and inserted into rundata in the action class. There are two methods, getValue(column name) that returns data for a column and getChild(loop name) that returns a hierarchical dataset containing multiple rows of data. This JSP page displays all the past phone numbers and addresses of this user and allows the most recent to be edited.
  • Java source for the Action class: Uses Aspire, a declarative middle tier for all database transactions; see Figure 2 for the flow logic.
  • profile.xreg: Three additional parameters - aspireAction, aspireURL, and appName - have been added compared to the standard version. Values assigned to these parameters are used in buildNormalContext() to initialize the portlet and get the initial set of data from the database through Aspire.
  • Aspire properties file: The database calls are declaratively specified in this file. AspireURLs illustrated here are "SaveAddress" and "addressURL." dprDB is an alias for a database. In SaveAddress, the first part of request gets user_id, and the second part executes an insert. In addressURL, there are three parts to the request: the first two return a single row and the third returns multiple rows.
Summary
A broker class is presented as a means of simplifying the process of creating JSP portlets. The custom Java coding-based approach in the action class is replaced with a declarative approach in which data access and update methods are specified in external properties files. This greatly simplifies the development and maintenance of portlets.

More Stories By Satya Komatenini

Satya Komatineni is Chief Technology Officer of INDENT, Inc and the author of a Java based RAD framework for developing J2EE based HTML applications. The product has the distinction of supporting multiple html transformations (XSL,JSP, proprietary templates) while utilizing the same data abstraction to interact with EJBs, relational databases and ERP systems. After earning an M.S. in Electrical Engineering from Indian Institute of Technology, New Delhi, worked with LAN based collaboration technologies, C++ patterns and frameworks, Java and Web based frameworks in a distributed environment.

More Stories By Pramod Jain

Pramod Jain is president of Innovative Decision Technologies, Inc. (INDENT, www.indent.org), in Jacksonville, FL. Their clients include Recruitmax, NASA, and NIH. Pramod has a PhD from the University of California, Berkeley.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that Datanami has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Datanami is a communication channel dedicated to providing insight, analysis and up-to-the-minute information about emerging trends and solutions in Big Data. The publication sheds light on all cutting-edge technologies including networking, storage and applications, and the...
SYS-CON Events announced today that EnterpriseTech has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. EnterpriseTech is a professional resource for news and intelligence covering the migration of high-end technologies into the enterprise and business-IT industry, with a special focus on high-tech solutions in new product development, workload management, increased effi...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
In this presentation, Striim CTO and founder Steve Wilkes will discuss practical strategies for counteracting fraud and cyberattacks by leveraging real-time streaming analytics. In his session at @ThingsExpo, Steve Wilkes, Founder and Chief Technology Officer at Striim, will provide a detailed look into leveraging streaming data management to correlate events in real time, and identify potential breaches across IoT and non-IoT systems throughout the enterprise. Strategies for processing massive ...
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organi...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
SYS-CON Events announced today that TMC has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo and Big Data at Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Global buyers rely on TMC’s content-driven marketplaces to make purchase decisions and navigate markets. Learn how we can help you reach your marketing goals.
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
"MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
Multiple data types are pouring into IoT deployments. Data is coming in small packages as well as enormous files and data streams of many sizes. Widespread use of mobile devices adds to the total. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists looked at the tools and environments that are being put to use in IoT deployments, as well as the team skills a modern enterprise IT shop needs to keep things running, get a handle on all this data, and deliver...
The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.