I have tried everything to run my first Struts2 demo application but i am failed to run it. I have followed the tutorial on
http://www.quickprogrammingtips.com/struts2/struts-2-netbeans-tutorial.html
Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<display-name>Struts2 Demo App</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Here is my struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="Struts2Demo" extends="struts-default">
<action name="HelloWorld" class="controller.HelloWorld">
<result>/message.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
here is controller file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;
import com.opensymphony.xwork2.ActionSupport;
import model.Message;
public class HelloWorld extends ActionSupport {
private Message message;
@Override
public String execute() {
setMessage(new Message()); // get data from model
return SUCCESS;
}
public Message getMessage() {
return message;
}
public void setMessage(Message message) {
this.message = message;
}
}
Here is my jsp file
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="Struts2Demo" extends="struts-default">
<action name="HelloWorld" class="controller.HelloWorld">
<result>/message.jsp</result>
</action>
<!-- Add your actions here -->
</package>
</struts>
and here is the model file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package model;
public class Message {
private String message = "Hello World!";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
My file structure is
Netbeans version: 8.1 Glassfish server: 4 All struts2 configuration are setup manually without any plugin