Click hereto download the complete application without Jar Dependency (few KBs)
This file does not contain the jars. If you would like to download the application with the jars , » Read more: Simple Struts Example Zip File
Click hereto download the complete application without Jar Dependency (few KBs)
This file does not contain the jars. If you would like to download the application with the jars , » Read more: Simple Struts Example Zip File
After your workspace is ready, » Read more: Struts Tutorial – Eclipse Workspace Setup Video
package com;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head></head>
<body>
<p>This is my first struts example </p>
</body>
</html>
<?xml version=”1.0″ encoding=”ISO-8859-1″ ?>
<!DOCTYPE struts-config PUBLIC
“-//Apache Software Foundation//DTD Struts Configuration 1.2//EN”
“http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd”><struts-config>
Copy the contents below and save it in web.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app id=”WebApp_ID” version=”2.4″
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”>
What this tutorial will do is help you get started with a simple example of forwarding a request to a jsp.This is a practical tutorial so lets gets started .
1. Make sure you have an Application Server Installed on your system . For this demo I am using Tomcat 5.5.
2. Download Eclipse or any other IDE (This step is optional and would help in case you would like to follow the Video tutorial of Struts which would be posted in a few days. ). I am using Eclipse.
3. Sample Web.xml
4.Sample struts-config.xml
5. Sample Java Class (Action Class)
6. How to Configure your Server – Video
In case you have any other queries , please feel free to leave a comment and we would love to help you out .