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/asia/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.

Asset Management for Net-Zero Futures

Asset Management for Net-Zero Futures

Sustainability is not a new concept and BPD Zenith have always strived to be socially responsible, however, it is a critical imperative for today’s business operations – and for the planet... There has been a shift from using digital to improve the bottom line, to...

The Hidden Value of CMMS Master Data

The Hidden Value of CMMS Master Data

Having made a significant investment in your CMMS, advances in Data analytics are prompting rethinks about the Master Data that underpins your ability to launch programs such as Asset performance management, Monitor Asset health and enhance Predictive Maintenance. A...

IBM Champion 2022 Spotlight – Nivin George

Tell me a bit about yourself? What do you do at BPD Zenith. Before moving to Australia, I have been working with Maximo since 2004 in the Middle East and have played a major role in implementations, upgrades, integration, reporting and pre-sales for many...

BPD in Offshore: When the wind blows, our assets perform…

BPD in Offshore: When the wind blows, our assets perform…

London Array Limited (LAL) maintain a critical electricity production wind farm in the Outer Thames Estuary.   Lucy Horner (then Maintenance Strategy Engineer) joined the AiTalks podcast last year to discuss her world of offshore wind provision, the levels of...

Happy International Woman’s Day 2022 – Woman in Tech

Happy International Woman’s Day 2022 – Woman in Tech

International Woman’s day, which is celebrated globally on the 8th of March, commemorates the cultural, socioeconomic and political achievements of woman across the globe with a strong focus on gender equality, and on preventing violence and abuse against woman. The...

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.