Struts Hello World Example

In this tutorial we show you how to develop a hello world web application using classic Struts 1.3 framework.

Tools and technologies used :

  1. Struts 1.3.10
  2. Maven 2.x
  3. Eclipse 3.6

Final project structure

Let’s see the final folder structure first.

Struts-Hello-World-Maven

1. Maven Template

Generate a quick start Java project structure with Maven command “mvn archetype:generate“, select template 18 for a simple Java web project template.

Define value for groupId: : com.mkyong.common
Define value for artifactId: : StrutsExample
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  com.mkyong.common: : com.mkyong.common
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 5 seconds
[INFO] Finished at: Thu Apr 08 11:29:30 SGT 2010
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------

2. pom.xml file configuration

Add the Struts dependencies in pom.xml. In Struts 1.x, you need the struts-core.jar for core module and struts-taglib.jar for tag library.

<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mkyong.common</groupId>
  <artifactId>StrutsExample</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>StrutsExample Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
 
    <dependency>
      <groupId>org.apache.struts</groupId>
	  <artifactId>struts-core</artifactId>
      <version>1.3.10</version>
    </dependency>
 
    <dependency>
      <groupId>org.apache.struts</groupId>
	  <artifactId>struts-taglib</artifactId>
      <version>1.3.10</version>
    </dependency>
 
  </dependencies>
  <build>
    <finalName>StrutsExample</finalName>
  </build>
</project>

3. Eclipse IDE

Convert this project to Eclipse web project with Maven command “mvn eclipse:eclipse -Dwtpversion=1.5“. All the Struts dependent libraries will automatically download into your Maven local repository, link it in your project classpath, and convert it to Eclipse’s web project style.

E:\workspace\struts\StrutsExample>mvn eclipse:eclipse -Dwtpversion=1.5
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building StrutsExample Maven Webapp

Just import it into Eclipse IDE.

4. Action Form

Create a Struts Action Form to hold the “hello world” data later.

package com.mkyong.common.form;
 
import org.apache.struts.action.ActionForm;
 
public class HelloWorldForm extends ActionForm{
 
	String message;
 
	public String getMessage() {
		return message;
	}
 
	public void setMessage(String message) {
		this.message = message;
	}
 
}

5. Action (Controller)

Create a Struts Action (Action Controller) file to control how Struts will forward the request, just override the execute() method with your own logic here.

package com.mkyong.common.action;
 
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;
 
import com.mkyong.common.form.HelloWorldForm;
 
public class HelloWorldAction extends Action{
 
	public ActionForward execute(ActionMapping mapping,ActionForm form,
		HttpServletRequest request,HttpServletResponse response)
        throws Exception {
 
		HelloWorldForm helloWorldForm = (HelloWorldForm) form;
		helloWorldForm.setMessage("Hello World! Struts");
 
		return mapping.findForward("success");
	}
 
}

6. JSP view page

Create a JSP page and access the Action Form object via Struts tag library and print it’s message property.

<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<html>
<head>
</head>
<body>
<h1><bean:write name="helloWorldForm" property="message" />
</h1>
</body>
</html>

7. struts-config.xml

Create a struts-config.xml file for the Struts configuration details, and put it into the WEB-INF folder.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
"http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">
 
<struts-config>
 
	<form-beans>
	   <form-bean name="helloWorldForm" 
		type="com.mkyong.common.form.HelloWorldForm"/>
	</form-beans>
 
	<action-mappings>
	   <action path="/helloWorld"
		type="com.mkyong.common.action.HelloWorldAction"
		name="helloWorldForm">
		<forward name="success" path="/HelloWorld.jsp"/>
 
	   </action>
	</action-mappings>
 
</struts-config>

Define a form bean named “helloWorldForm” and action controller mapping “HelloWorldAction“, match the /helloWorld web path to HelloWorldAction. It’s means all the request from /helloWorld web path will redirect to HelloWorldAction. The “name” attribute is use to define which action form will pass to this HelloWorldAction.

8. The Web Application Deployment Descriptor

In web.xml file, configure the Struts ActionServlet instance and map it with url-pattern “*.do”, so that the container is aware of all the “*.do” pattern will redirect to Struts ActionServlet.

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
 
<web-app>
  <display-name>Maven Struts Examples</display-name>
 
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>
        org.apache.struts.action.ActionServlet
    </servlet-class>
    <init-param>
        <param-name>config</param-name>
        <param-value>
         /WEB-INF/struts-config.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet-mapping>
       <servlet-name>action</servlet-name>
       <url-pattern>*.do</url-pattern>
  </servlet-mapping>
 
</web-app>

9. Java EE Module dependency (Optional)

If you want to do the debugging work in Eclipse IDE, you have to make sure the Java EE module dependencies is checked so that the Eclipse will deploy all the dependencies into correct folder. See details here.

10. Run it

In Eclipse IDE, create a new server plugin and start it. You can access this example in the following URL.

http://localhost:8080/StrutsExample/helloWorld.do

Struts-Hello-World-Maven2
HttpServletRequest class not found?
If you hit above error, make sure you include the javaee.jar (exists in your JDK/lib folder). Due to license issue, this javaee.jar is not able to use Maven to download it, you have to include it manually.

Download

Reference

Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: stop parking()

  • Pingback: water ionizer()

  • Pingback: laan penge nu()

  • Pingback: 3gp mobile porn()

  • Pingback: stop parking()

  • Pingback: water ionizer()

  • Pingback: alkaline water()

  • Pingback: watch tv show episodes()

  • Pingback: watch tv show episodes()

  • Pingback: watch movies online()

  • Pingback: Blue Coaster33()

  • ekansh

    you can also try this example –this is much simple

    http://www.ekjam.com/pages/tutorials/struts/helloWorld.jsp

  • Peter Tarlos

    If you’re getting error:

    Stacktrace:] with root cause
    javax.servlet.jsp.JspException: Cannot find bean: ?helloWorldForm? in any scope
    at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:934)

    Remember to call the URL below, as instructed by the article, and not the “HelloWorld.jsp” directly. If you call the jsp directly it will not work because the struts action hasn’t set the form yet.
    http://localhost:8080/StrutsExample/helloWorld.do

  • https://www.usasa.org/forum/10-usasa-judging-questions/18156-bd3p--metro-uxd-qr.html#18156 goods

    My husband and i got really excited when Michael could finish off his homework via the ideas he made out of the blog. It is now and again perplexing to just possibly be giving out information and facts which usually many people could have been selling. And we already know we now have the website owner to be grateful to for this. The entire explanations you have made, the straightforward site menu, the friendships your site assist to instill – it’s many remarkable, and it is helping our son and us consider that the article is interesting, and that is quite important. Many thanks for all the pieces!

  • http://gulshanehadeedstrangers.blogspot.com kas5986

    I have tried it creating new and also try to work download your sample and go to the url but it say page not found i have donwload javaee.jar and place it to JDK/lib folder also in tomcat lib but it still say page not found with both mine and your sample too can you tell me where i am wrong ?

  • Ian

    btw here is the link where the error happens

    http://sample.com/goalsunlimited/systemLogin.do

    Here are the configs:

    *******
    web.xml
    *******

    goalsunlimited

    action
    org.apache.struts.action.ActionServlet

    config
    /WEB-INF/struts-config.xml

    debug
    2

    detail
    2

    2

    action
    *.do

    login.jsp

    60

    /WEB-INF/struts-bean.tld
    /WEB-INF/struts-bean.tld

    /WEB-INF/struts-html.tld
    /WEB-INF/struts-html.tld

    /WEB-INF/struts-logic.tld
    /WEB-INF/struts-logic.tld

    /WEB-INF/struts-nested.tld
    /WEB-INF/struts-nested.tld

    /WEB-INF/struts-tiles.tld
    /WEB-INF/struts-tiles.tld

    java.lang.Exception
    /error.jsp

    javax.servlet.jsp.jstl.fmt.localizationContext
    MessageResources

    *****************
    struts-config.xml
    *****************

    **********
    spring.xml
    **********

    classpath:com/mlm/dao/SqlMapConfig.xml

    true

  • Luciano Straga

    I’m new in Struts, I’m getting every time a 404 error, after following all the steps described. I deployed successfully the war file with maven, it’s apparentliy running in tomcat’s mannager; but I get the 404. I reviewed all the paths of the files, to discard path mistakes but i couldn’t find the solution.

    Thanks for all, mkyong

  • Milan

    e learning from this website will surely improve struts skills.

  • lonia

    I download the zip and I try to run it but I have this error.

    Stacktrace:] with root cause
    javax.servlet.jsp.JspException: Cannot find bean: “helloWorldForm” in any scope
    at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:864)
    at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:233)
    at org.apache.jsp.pages.HelloWorld_jsp._jspx_meth_bean_005fwrite_005f0(HelloWorld_jsp.java:106)
    at org.apache.jsp.pages.HelloWorld_jsp._jspService(HelloWorld_jsp.java:76)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

    Can you help me please!

    • Ivo

      I think it’s a typo, replace helloWorldForm with HelloWorldForm (capital H).

      Hope this helps :)

  • Pingback: ????????????? ????? » Blog Archive » ???????? ? «HelloWorld» ??????????? ?? Struts2()

  • Pingback: Criando um Módulo Personalizado no JBoss AS 7.1.2 (JBoss EAP 6) | JBossDivers()

  • rijesh

    Hii
    While running above program i got error as like this,please help me….

    SEVERE: Servlet /Strut threw load() exception
    java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1136)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

  • http://NA Vinayak

    Done with all steps. build is successful. Tomcat is configured. HTTP 404 -/StrutsExmaples/helloWorld.do
    Please help.

  • Vinayak

    Hi I am new to struts & done with maven setup. if I will go to bin folder of maven & check version from command prompt, I get details of maven. when I try to enter details with mvn command- archetype:generate & enter all as below

    groupId: : com.mkyong.common
    Define value for artifactId: : StrutsExample
    Define value for version: 1.0-SNAPSHOT: :
    Define value for package: com.mkyong.common: : com.mkyong.common

    it do not accept any value. Please suggest me..how run this program…if first program will be done….I would be able to do rest all.

  • erkan

    your sample is doesnt work :(

    • http://www.mkyong.com mkyong

      What doesn’t works?

      • erkan

        sorry,it is working

      • Sandhya

        I am getting this error when tried run the example:

        4:
        5:
        6:
        7:
        8:
        9:
        10:

        Stacktrace:] with root cause
        javax.servlet.jsp.JspException: Cannot find bean: “helloWorldForm” in any scope
        at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:934)
        at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:225)
        at org.apache.jsp.index2_jsp._jspx_meth_bean_005fwrite_005f0(index2_jsp.java:104)
        at org.apache.jsp.index2_jsp._jspService(index2_jsp.java:73)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

        Please help me on this.

  • Hardik Patel

    i can’t getting this.

    &lt;init-param&gt;
            &lt;param-name&gt;config&lt;/param-name&gt;
            &lt;param-value&gt;
             /WEB-INF/struts-config.xml
            &lt;/param-value&gt;
       &lt;/init-param&gt;
  • Hardik Patel

    i can’t getting this.

    config

    /WEB-INF/struts-config.xml

  • Hardik Patel

    config

    /WEB-INF/struts-config.xml

    I can’t getting above…please help.

  • Pingback: Google App Engine + Struts 1 example()

  • http://www.mkyong.com/struts/struts-hello-world-example/ dhruv

    Really i love this website . from where we can learn lot of concepts of java and lastly i want to say this website is my carrier. thank you

    • Venkata Tekkem

      //Really i love this website . from where we can learn lot of concepts of java and lastly i want to say this website is my carrier. thank you//

      SAME HERE

      Thank you mkyong

  • Ogi

    i think you need to add the following dependency in the pom.xml

    &lt;dependency&gt;
    	&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
    	&lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
    	&lt;version&gt;2.3&lt;/version&gt;
    	&lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  • Lijun

    It is un problem with:
    org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
    at org.apache.struts.chain.commands.AbstractSelectAction.execute(AbstractSelectAction.java:71)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)

    • Ian

      Hi I have a struts application. It is working in my laptop but when I deploy it in another server or tomcat I am getting the following error. Please someone help me. Thanks!

      Mar 23, 2013 3:26:50 PM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet action threw exception
      org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.
      at org.apache.struts.chain.commands.AbstractSelectAction.execute(AbstractSelectAction.java:71)
      at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
      at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
      at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
      at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
      at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
      at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
      at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
      at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
      at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
      at java.lang.Thread.run(Thread.java:619)

      • Ian

        btw here is the link where the error happens

        http://sample.com/goalsunlimited/systemLogin.do

        Here are the configs:

        *******
        web.xml
        *******

        goalsunlimited

        action
        org.apache.struts.action.ActionServlet

        config
        /WEB-INF/struts-config.xml

        debug
        2

        detail
        2

        2

        action
        *.do

        login.jsp

        60

        /WEB-INF/struts-bean.tld
        /WEB-INF/struts-bean.tld

        /WEB-INF/struts-html.tld
        /WEB-INF/struts-html.tld

        /WEB-INF/struts-logic.tld
        /WEB-INF/struts-logic.tld

        /WEB-INF/struts-nested.tld
        /WEB-INF/struts-nested.tld

        /WEB-INF/struts-tiles.tld
        /WEB-INF/struts-tiles.tld

        java.lang.Exception
        /error.jsp

        javax.servlet.jsp.jstl.fmt.localizationContext
        MessageResources

        *****************
        struts-config.xml
        *****************

        **********
        spring.xml
        **********

        classpath:com/mlm/dao/SqlMapConfig.xml

        true

        • Ian

          btw here is the link where the error happens

          http://sample.com/goalsunlimited/systemLogin.do

          Here are the configs:

          *******
          web.xml
          *******

           
          &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
          &lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;2.5&quot;&gt;
            &lt;display-name&gt;goalsunlimited&lt;/display-name&gt;
            &lt;servlet&gt;
                  &lt;servlet-name&gt;action&lt;/servlet-name&gt;
                  &lt;servlet-class&gt;org.apache.struts.action.ActionServlet&lt;/servlet-class&gt;
                  &lt;init-param&gt;
                      &lt;param-name&gt;config&lt;/param-name&gt;
                      &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt;
                  &lt;/init-param&gt;
                  &lt;init-param&gt;
                      &lt;param-name&gt;debug&lt;/param-name&gt;
                      &lt;param-value&gt;2&lt;/param-value&gt;
                  &lt;/init-param&gt;
                  &lt;init-param&gt;
                      &lt;param-name&gt;detail&lt;/param-name&gt;
                      &lt;param-value&gt;2&lt;/param-value&gt;
                  &lt;/init-param&gt;
                  &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
              &lt;/servlet&gt;
           
              &lt;servlet-mapping&gt;
                  &lt;servlet-name&gt;action&lt;/servlet-name&gt;
                  &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
              &lt;/servlet-mapping&gt;    
           
              &lt;welcome-file-list&gt;
                  &lt;welcome-file&gt;login.jsp&lt;/welcome-file&gt;
              &lt;/welcome-file-list&gt;
           
              &lt;session-config&gt;
                &lt;session-timeout&gt;60&lt;/session-timeout&gt;
              &lt;/session-config&gt;
           
              &lt;jsp-config&gt;
                  &lt;taglib&gt;
                      &lt;taglib-uri&gt;/WEB-INF/struts-bean.tld&lt;/taglib-uri&gt;
                      &lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt;
                  &lt;/taglib&gt;
                  &lt;taglib&gt;
                      &lt;taglib-uri&gt;/WEB-INF/struts-html.tld&lt;/taglib-uri&gt;
                      &lt;taglib-location&gt;/WEB-INF/struts-html.tld&lt;/taglib-location&gt;
                  &lt;/taglib&gt;
                  &lt;taglib&gt;
                      &lt;taglib-uri&gt;/WEB-INF/struts-logic.tld&lt;/taglib-uri&gt;
                      &lt;taglib-location&gt;/WEB-INF/struts-logic.tld&lt;/taglib-location&gt;
                  &lt;/taglib&gt;
                  &lt;taglib&gt;
                      &lt;taglib-uri&gt;/WEB-INF/struts-nested.tld&lt;/taglib-uri&gt;
                      &lt;taglib-location&gt;/WEB-INF/struts-nested.tld&lt;/taglib-location&gt;
                  &lt;/taglib&gt;
                  &lt;taglib&gt;
                      &lt;taglib-uri&gt;/WEB-INF/struts-tiles.tld&lt;/taglib-uri&gt;
                      &lt;taglib-location&gt;/WEB-INF/struts-tiles.tld&lt;/taglib-location&gt;
                  &lt;/taglib&gt;
          	&lt;/jsp-config&gt;
           
           
              &lt;error-page&gt;
                  &lt;exception-type&gt;java.lang.Exception&lt;/exception-type&gt;
                  &lt;location&gt;/error.jsp&lt;/location&gt;
              &lt;/error-page&gt;
           
              &lt;context-param&gt;
                  &lt;param-name&gt;javax.servlet.jsp.jstl.fmt.localizationContext&lt;/param-name&gt;
                  &lt;param-value&gt;MessageResources&lt;/param-value&gt;
              &lt;/context-param&gt;
          &lt;/web-app&gt;

          *****************
          struts-config.xml
          *****************

           
          &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
           
          &lt;!DOCTYPE struts-config PUBLIC
                  &quot;-//Apache Software Foundation//DTD Struts Configuration 1.2//EN&quot;
                  &quot;http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd&quot;&gt;
           
          &lt;struts-config&gt;
              &lt;form-beans&gt;    	
          		&lt;form-bean name=&quot;registrationForm&quot; type=&quot;com.mlm.form.RegistrationForm&quot;/&gt;
          		&lt;form-bean name=&quot;memberForm&quot; type=&quot;com.mlm.form.MemberForm&quot;/&gt;
          		&lt;form-bean name=&quot;loginForm&quot; type=&quot;com.mlm.form.MemberForm&quot;/&gt;
              &lt;/form-beans&gt;    
           
              &lt;action-mappings&gt;
              	&lt;!-- LOG IN --&gt;
              	&lt;action
                          path=&quot;/systemLogin&quot;
                          name=&quot;loginForm&quot;
                          validate=&quot;false&quot;
                          input=&quot;/login.jsp&quot;
                          type=&quot;org.springframework.web.struts.DelegatingActionProxy&quot;
                          scope=&quot;session&quot;
                          parameter=&quot;method&quot;&gt;                        
                      &lt;forward name=&quot;success&quot; path=&quot;/getAccountSummary.do?method=getAccountSummary&quot;/&gt;
                      &lt;forward name=&quot;failure&quot; path=&quot;/login.jsp&quot;/&gt;            
                  &lt;/action&gt;
          	&lt;/action-mappings&gt;    
           
              &lt;message-resources parameter=&quot;MessageResources&quot; null=&quot;false&quot;/&gt;
           
              &lt;plug-in className=&quot;org.springframework.web.struts.ContextLoaderPlugIn&quot;&gt;
                  &lt;set-property property=&quot;contextConfigLocation&quot; value=&quot;/WEB-INF/spring.xml&quot;/&gt;
              &lt;/plug-in&gt;
           
              &lt;plug-in className=&quot;org.apache.struts.validator.ValidatorPlugIn&quot;&gt;
          		&lt;set-property property=&quot;pathnames&quot; 
          			value=&quot;/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml&quot;/&gt;
          	&lt;/plug-in&gt;  
          &lt;/struts-config&gt;

          **********
          spring.xml
          **********

           
          &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
          &lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot;
                  &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;
           
          &lt;beans&gt;
           
              &lt;bean id=&quot;propertyConfigurer&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
                  &lt;property name=&quot;location&quot; value=&quot;classpath:spring.properties&quot;/&gt;
              &lt;/bean&gt;   
           
              &lt;bean name=&quot;/systemLogin&quot; class=&quot;com.mlm.action.LoginAction&quot;&gt;
              	&lt;property name=&quot;memberService&quot;&gt;
          			&lt;ref bean=&quot;memberService&quot;/&gt;
          		&lt;/property&gt;		
              &lt;/bean&gt;   
           
              &lt;bean id=&quot;dataSource&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot;&gt;
                  &lt;property name=&quot;driverClassName&quot; value=&quot;${driverClassName}&quot;/&gt;
                  &lt;property name=&quot;url&quot; value=&quot;${url}&quot;/&gt;
                  &lt;property name=&quot;username&quot; value=&quot;${username}&quot;/&gt;
                  &lt;property name=&quot;password&quot; value=&quot;${password}&quot;/&gt;
              &lt;/bean&gt;
           
              &lt;bean id=&quot;sqlMapClient&quot;
                    class=&quot;org.springframework.orm.ibatis.SqlMapClientFactoryBean&quot;&gt;
                  &lt;property name=&quot;configLocation&quot;&gt;
                      &lt;value&gt;classpath:com/mlm/dao/SqlMapConfig.xml&lt;/value&gt;
                  &lt;/property&gt;
                  &lt;property name=&quot;useTransactionAwareDataSource&quot;&gt;
                      &lt;value&gt;true&lt;/value&gt;
                  &lt;/property&gt;
                  &lt;property name=&quot;dataSource&quot;&gt;
                      &lt;ref bean=&quot;dataSource&quot;/&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
           
              &lt;bean id=&quot;sqlMapClientTemplate&quot;
                    class=&quot;org.springframework.orm.ibatis.SqlMapClientTemplate&quot;&gt;
                  &lt;property name=&quot;sqlMapClient&quot;&gt;
                      &lt;ref bean=&quot;sqlMapClient&quot;/&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
           
              &lt;bean id=&quot;memberDao&quot; class=&quot;com.mlm.dao.MemberDaoImpl&quot;&gt;
                  &lt;property name=&quot;sqlMapClient&quot;&gt;
                      &lt;ref bean=&quot;sqlMapClient&quot;/&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
           
              &lt;bean id=&quot;memberService&quot; class=&quot;com.mlm.service.impl.MemberServiceImpl&quot;&gt;
                  &lt;constructor-arg index=&quot;0&quot; ref=&quot;memberDao&quot;/&gt;
              &lt;/bean&gt;
          &lt;/beans&gt;
  • Pingback: Struts Tutorials | Tutorials()