THE BPD Blog

From blogs to case studies to news, we love sharing our tips and tricks for asset management, cloud, IoT and smarter operations.

by | Sep 13, 2021

Custom servlet in Maximo

What is a servlet?

Servlets are Java classes which service HTTP requests and implement the ‘javax. servlet. HttpServlet’, an abstract class that implements the servlet interface and is specially designed to handle HTTP requests.

A  servlet accepts the request, processes it, creates a data package, and serves it as response.

Processing usually includes access to databases, fetching data and conversion to object models of convenience. Objects can be JSON, XML, reports, or files exported to a hard disk.

Examples of custom servlets in Maximo are showing images, print attachments, print BIRT reports, export integration files, REST integration, REST token authentication or print various other documents.

 A custom servlet usage scenario

To demonstrate the use of a custom servlet, I will show an example of its use in Maximo.

First, let us imagine a scenario where this servlet will be used:

As a part of RFQ process, a user wants to export quotation lines into a file and send it to the vendor. The user wants to minimize possibilities of error while populating data.

For that purpose, we will create an excel file with extra twists. This includes:

  • vendor specific passwords on the excel sheet,
  • some fields set as read only,
  • fields set as calculated, and
  • fields that have domains in Maximo which will have attached drop down lists with domain values.

This way, vendors only have to populate editable fields quantity and unit cost.

The user wants the action to be triggered at a certain point, through a download button or as a part of the WF process.

How is a custom servlet implemented?

In RFQAppBean we will create an event/method that looks like this:

At some point, while in RFQ application, with relevant RFQ displayed, ‘download event’ will be triggered.

The event will store RfqNum in session and invoke a servlet.

The second step is to define the servlet in web.xml.

Lines to be added are:

The final step is to create a custom class for the servlet. A custom class would look like this:

We are using HSSF (or XSSF) excel library to create an excel workbook from scratch. Creation logic is encapsulated within class ‘RFQLinesDownload()’.

Eventually, the workbook will be streamed to a response. As you can see the output will be a real excel file (not csv).

This is just one example of custom servlet usage among many possibilities. Implementing functionality is relatively easy. There are many ways to use it and they are limited only by your (and your client’s) imagination.

 

And at the end, here are some bonus excerpts from the ‘RFQLinesDownload()’ class:

How to put a password on excel sheets:

How to create a calculated field:

Finally, click here if you would like to learn more about Maximo in one of my previous blog posts ‘Maximo and Attachments’.

If you would like to learn more about features of Maximo that BPD Zenith can offer, you can contact us at: https://www.bpdzenith.com/contact/

Velibor Djukic

Velibor Djukic

Velibor has been working with Maximo for more than 13 years in Middle East and Australia. He had been working as Team Lead on large scale Maximo project such as KOC (Kuwait Oil Company). He spent last couple of years in Mobile space working with Anywhere, EZMax, and Datasplice. Currently works as Solution Architect for BPD Zenith Australia and like to share knowledge with everybody who seeks it.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

9 Recommendations For A Successful SAP & IBM Maximo EAM Interface

9 Recommendations For A Successful SAP & IBM Maximo EAM Interface

Integration is often a key component for getting the most out of your critical IT applications. Modern Enterprise Asset Management systems such as IBM Maximo are designed for integration which can expand their capabilities and allow the flexibility that the industry...

Reinvent the Wheel with BPD Zenith’s Maximo Accelerators

Reinvent the Wheel with BPD Zenith’s Maximo Accelerators

I was recently involved in preparing a business case for a Maximo implementation, and as a part of process I spent considerable time analyzing and evaluating the best approach. In essence, I was trying to find the optimum balance between minimizing the length of the...

Defence Seaworthiness – A session from AMPEAK 2021

Defence Seaworthiness – A session from AMPEAK 2021

I recently got the opportunity to attend Asset Management Council of Australia’s AMPEAK conference. It has been a great experience interacting directly with the true practitioners of Asset Management, and understanding some of the technology challenges that they are...

Sign up to our free newsletter to explore emerging technologies, industry events and Maximo best practice.

Come with BPD Zenith to the future of Asset Management

Partner Ecosystem

BPD Zenith partners with a diverse array of the world’s top Technology, Business and Solution Integration leaders.