As a prolongation of my previous post on Hacking Infor Grid application development, this time I will show you how to add a simple HelloWorld servlet to your Infor Grid application.
HelloWorld servlet
Create a simple HelloWorld servlet:
package net.company.your; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorldServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("HelloWorld servlet! The time is " + new Date()); out.println("</body>"); out.println("</html>"); } }
Compile it with the Servlet API library that you can find in the LifeCycle Manager runtime:
E:\LifeCycle\<host>\grid\<grid>\runtimes\1.11.27\resources\servlet-api-2.5.jar
javac -cp servlet-api-2.5.jar WEB-INF\classes\net\company\your\HelloWorldServlet.java
Deployment descriptor
Create a simple deployment descriptor web.xml:
<?xml version="1.0" encoding="utf-8" ?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>HelloWorld Servlet</display-name> <description>My HelloWorld servlet</description> <servlet> <servlet-name>HelloWorldServlet</servlet-name> <servlet-class>net.company.your.HelloWorldServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/sup</url-pattern> </servlet-mapping> </web-app>
File & folder structure
Set the following file & folder structure in a WEB-INF directory:
\---HelloWorld ... \---webapps \---HelloWorld ... \---WEB-INF | web.xml | \---classes \---net \---company \---your HelloWorldServlet.class
With Eclipse
You can also use Eclipse to create the servlet and deployment descriptor and to compile:
Deploy
You can create and deploy your servlet as a new application, or you can add WEB-INF to an existing application in LifeCycle Manager at:
E:\LifeCycle\<host>\grid\<grid>\grids\<grid>\applications\HelloWorld\webapps\HelloWorld\WEB-INF\
If you choose hot deployment, reload the Grid application module:
Result
You can now test the result in a browser:
Summary
That was how to add a simple servlet to your Infor Grid application. Next time, I will explore how to add JAR files and how to deploy a WAR file.
That’s it! Like + comment + subscribe + share.
Thumbs up Thibaud! Especially for: “This is my call to Infor Product Development. If you are reading this, please jailbreak the Grid, release the tools and documentation and embrace the community. Help us reach a mutually beneficial relationship where great ideas can get out of anonymity and flourish”
(Could not comment on the previous post)
LikeLike
Bonjour Guillaume. Thank you. Yes, call your Infor representatives and let them know 😉 I wish they would open source Infor Grid application development, Smart Office, Infor Process Automation, Mashups, and more, at least for debugging and testing purposes. They already opened the source of M3 Java programs, why not open to more. I may start a petition.
LikeLike
Guillaume, sign the petition: https://thibaudatwork.wordpress.com/2014/07/28/infor-product-development-make-the-source-code-available-sign-the-petition/
LikeLike
BTW – I found comments were accidentally disabled for previous post. Enabled now. Thanks for the info.
LikeLike