Using Mentawai with Codenvy

Create a project using our Factory button:

Mentawai is a full-stack, action-based, MVC open-source Java web framework born in June 2005. Since then It has been loyal to its philosophy which is to be a high-level web development solution without any XML or Annotations, using a centralized programmatic configuration to wire up the web stack. It embraces the KISS principle through high levels of abstraction. If you are not able to do or understand something related to the framework, the framework is the one to blame, not you.

One of the main characteristics of Mentawai is its full-stack approach since its inception, in other words, you won’t be needing any other framework to implement all the diverse features of most web applications. Everything is abstracted and given by the framework out-of-the-box. This is the same approach used by other frameworks such as Ruby on Rails, Play and Riffe.

By favoring a programmatic approach to configuration Mentawai eliminates XML and Annotations programming, very common to the majority of Java frameworks. The framework was the first Java web framework to follow this path back in 2005.

Create a Project

Login to your codenvy workspace and create a New WAR Project say “mentawai”. Project file structure is shown below :

GetImage (9)

Add Dependencies

Specify the below dependencies in pom.xml which are prerequisites. Make sure these jars are included under Maven Dependencies.

GetImage (10)

Pom.xml :


Create Action Class

In this example, we create an Action class to greet the User.
Mentawai uses the Input and the Output to get information from the request and send information back as a response.

Code Logic :

package com.codenvy.action;
import org.mentawai.core.BaseAction;

public class GreetAction extends BaseAction {
public String sayHello() {
String msg = input.getString("msg");
if (isEmpty(msg)) {
msg = "World!";
output.setValue("msg", msg);
return SUCCESS;

Create ApplicationManager Class :
In this example, we create a ApplicationManager Class to load actions and serve requests and responses.
The action will respond to requests to /Greet.sayHello.mtw, its implementation comes from the GreetAction.class and the method that will handle the request is the sayHello().

Code Logic :

package com.codenvy;

import com.codenvy.action.GreetAction;
import org.mentawai.core.ApplicationManager;

public class AppManager extends ApplicationManager {

public void loadActions() {
action("/Greet", GreetAction.class, "sayHello").on(SUCCESS, fwd("/hello.jsp"));


Create index.jsp

Sample index page for the web application giving a sample text field to enter a name.

<%@page pageEncoding="UTF-8" %>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="mtw" uri=""%>
<mtw:form action="Greet.sayHello.mtw" method="post">
Enter your name: <mtw:input type="text" name="msg" size="30" maxlength="30" />
<input type="submit" value="Go!" />

Create hello.jsp :

Upon successfully response, this page is called and message is displayed to User.

<%@page pageEncoding="UTF-8" %>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="mtw" uri=""%>
Hello <mtw:out value="msg" />
Create web.xml:
<display-name>Mentawai Web Framework</display-name>


<!-- The Mentawai controller -->

<!-- You must choose an extension to indicate a mentawai action -->

In the web.xml one must indicate the full name of application manager class. In this case [ com.codenvy.AppManager ]

Build and Run the application

Upon successful building the application and running, it displays.

GetImage (11)

GetImage (12)