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/emea/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 *

Maximo Relationships

Maximo Relationships

In this blog I will be explaining what a Maximo Relationship is, how to create one, and, the benefits of having Maximo Relationships. What is a relationship? The way in which two or more things are connected, or the state of being connected.Why do we need Maximo...

Maximo Data Imports: A simplified guide

Maximo Data Imports: A simplified guide

All your Maximo data import needs simplified Being able to manage data loads and data extracts is a powerful ability. It can substantially improve processes and reduce delays. Maximo offers not one, but multiple ways of handling data. Equipped with user-friendly error...

Architecture Governance

Architecture Governance

What is architecture governance? Governance is a system of rules, practices, and processes by which a company is controlled and directed. It is less about deliberate control and strict adherence to rules, and more about the effective usage of resources to achieve an...

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.