Tutorial: Create Struts 2 Application in Eclipse

struts2-hello-world
Welcome to the Part 2 of 7-part series where we will explore the world of Struts 2 Framework. In previous article we went through the basics of Struts2, its Architecture diagram, the request processing lifecycle and a brief comparison of Struts1 and Struts2. If you have not gone through the previous article, I highly recommend you to do that before starting hands-on today.

Things We Need

Before we starts with our first Hello World Struts 2 Example, we will need few tools.

  1. JDK 1.5 above (download)
  2. Tomcat 5.x above or any other container (Glassfish, JBoss, Websphere, Weblogic etc) (download)
  3. Eclipse 3.2.x above (download)
  4. Apache Struts2 JAR files:(download). Following are the list of JAR files required for this application.
    • commons-logging-1.0.4.jar
    • freemarker-2.3.8.jar
    • ognl-2.6.11.jar
    • struts2-core-2.0.12.jar
    • xwork-2.0.6.jar

    Note that depending on the current version of Struts2, the version number of above jar files may change.

Our Goal

Our goal is to create a basic Struts2 application with a Login page. User will enter login credential and if authenticated successfully she will be redirected to a Welcome page which will display message ” Howdy, <username>…!“. If user is not authenticated, she will be redirected back to the login page.
struts2-application-login-page

Getting Started

Let us start with our first Struts2 based application.
Open Eclipse and goto File -> New -> Project and select Dynamic Web Project in the New Project wizard screen.
Dynamic Web Project in Eclipse

After selecting Dynamic Web Project, press Next.
Eclipse Struts2 Project

Write the name of the project. For example StrutsHelloWorld. Once this is done, select the target runtime environment (e.g. Apache Tomcat v6.0). This is to run the project inside Eclipse environment. After this press Finish.

Once the project is created, you can see its structure in Project Explorer.
Eclipse Project Explorer: Struts2 Example

Now copy all the required JAR files in WebContent -> WEB-INF -> lib folder. Create this folder if it does not exists.
struts2-webinf-jars

Mapping Struts2 in WEB.xml

As discussed in the previous article (Introduction to Struts2), the entry point of Struts2 application will be the Filter define in deployment descriptor (web.xml). Hence we will define an entry of org.apache.struts2.dispatcher.FilterDispatcher class in web.xml.

Open web.xml file which is under WEB-INF folder and copy paste following code.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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">

	<display-name>Struts2 Application</display-name>
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>
			org.apache.struts2.dispatcher.FilterDispatcher
		</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<welcome-file-list>
		<welcome-file>Login.jsp</welcome-file>
	</welcome-file-list>

</web-app>

The above code in web.xml will map Struts2 filter with url /*. The default url mapping for struts2 application will be /*.action. Also note that we have define Login.jsp as welcome file.

The Action Class

We will need an Action class that will authenticate our user and holds the value for username and password. For this we will create a package net.viralpatel.struts2 in the source folder. This package will contain the action file.
struts2-source-package
Create a class called LoginAction in net.viralpatel.struts2 package with following content.

package net.viralpatel.struts2;

public class LoginAction {
	private String username;
	private String password;

	public String execute() {

		if (this.username.equals("admin")
				&& this.password.equals("admin123")) {
			return "success";
		} else {
			return "error";
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}

Note that, above action class contains two fields, username and password which will hold the values from form and also contains an execute() method that will authenticate the user. In this simple example, we are checking if username is admin and password is admin123.

Also note that unlike Action class in Struts1, Struts2 action class is a simple POJO class with required attributes and method.

The execute() method returns a String value which will determine the result page. Also, in Struts2 the name of the method is not fixed. In this example we have define method execute(). You may want to define a method authenticate() instead.

The ResourceBundle

ResourceBundle is very useful Java entity that helps in putting the static content away from the source file. Most of the application define a resource bundle file such as ApplicationResources.properties file which contains static messages such as Username or Password and include this with the application.

ResourceBundle comes handy when we want to add Internationalization (I18N) support to an application.

We will define an ApplicationResources.properties file for our application. This property file should be present in WEB-INF/classes folders when the source is compiled. Thus we will create a source folder called resources and put the ApplicationResources.properties file in it.

To create a source folder, right click on your project in Project Explorer and select New -> Source Folder.
struts2-resource-folder
Specify folder name resources and press Finish.

Create a file ApplicationResources.properties under resources folder.
struts-2-application-resources-properties
Copy following content in ApplicationResources.properties.

label.username= Username
label.password= Password
label.login= Login

The JSP

We will create two JSP files to render the output to user. Login.jsp will be the starting point of our application which will contain a simple login form with username and password. On successful authentication, user will be redirected to Welcome.jsp which will display a simple welcome message.

Create two JSP files Login.jsp and Welcome.jsp in WebContent folder of your project. Copy following content into it.

Login.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Struts 2 - Login Application | ViralPatel.net</title>
</head>

<body>
<h2>Struts 2 - Login Application</h2>
<s:actionerror />
<s:form action="login.action" method="post">
	<s:textfield name="username" key="label.username" size="20" />
	<s:password name="password" key="label.password" size="20" />
	<s:submit method="execute" key="label.login" align="center" />
</s:form>
</body>
</html>

Welcome.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Welcome</title>
</head>

<body>
	<h2>Howdy, <s:property value="username" />...!</h2>
</body>
</html>

Note that we have used struts2 <s:> tag to render the textboxes and labels. Struts2 comes with a powerful built-in tag library to render UI elements more efficiently.

The struts.xml file

Struts2 reads the configuration and class definition from an xml file called struts.xml. This file is loaded from the classpath of the project. We will define struts.xml file in the resources folder. Create file struts.xml in resources folder.
struts2-struts-xml
Copy following content into struts.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
	<constant name="struts.enable.DynamicMethodInvocation"
		value="false" />
	<constant name="struts.devMode" value="false" />
	<constant name="struts.custom.i18n.resources"
		value="ApplicationResources" />

	<package name="default" extends="struts-default" namespace="/">
		<action name="login"
			class="net.viralpatel.struts2.LoginAction">
			<result name="success">Welcome.jsp</result>
			<result name="error">Login.jsp</result>
		</action>
	</package>
</struts>

Note that in above configuration file, we have defined Login action of our application. Two result paths are mapped with LoginAction depending on the outcome of execute() method. If execute() method returns success, user will be redirected to Welcome.jsp else to Login.jsp.

Also note that a constant is specified with name struts.custom.i18n.resources. This constant specify the resource bundle file that we created in above steps. We just have to specify name of resource bundle file without extension (ApplicationResources without .properties).

Our LoginAction contains the method execute() which is the default method getting called by Sturts2. If the name of method is different, e.g. authenticate(); then we should specify the method name in <action> tag.

	<action name="login" method="authenticate"
		class="net.viralpatel.struts2.LoginAction">

Almost Done

We are almost done with the application. You may want to run the application now and see the result yourself. I assume you have already configured Tomcat in eclipse. All you need to do:
Open Server view from Windows -> Show View -> Server. Right click in this view and select New -> Server and add your server details.
To run the project, right click on Project name from Project Explorer and select Run as -> Run on Server (Shortcut: Alt+Shift+X, R)

But there is one small problem. Our application runs perfectly fine at this point. But when user enters wrong credential, she is redirected to Login page. But no error message is displayed. User does not know what just happened. A good application always show proper error messages to user. So we must display an error message Invalid Username/Password. Please try again when user authentication is failed.

Final Touch

To add this functionality first we will add the error message in our ResourceBundle file.
Open ApplicationResources.properties and add an entry for error.login in it. The final ApplicationResources.properties will look like:

label.username= Username
label.password= Password
label.login= Login
error.login= Invalid Username/Password. Please try again.

Also we need to add logic in LoginAction to add error message if user is not authenticated. But there is one problem. Our error message is specified in ApplicationResources.properties file. We must specify key error.login in LoginAction and the message should be displayed on JSP page.

For this we must implement com.opensymphony.xwork2.TextProvider interface which provides method getText(). This method returns String value from resource bundle file. We just have to pass the key value as argument to getText() method. The TextProvider interface defines several method that we must implement in order to get hold on getText() method. But we don’t want to spoil our code by adding all those methods which we do not intend to use. There is a good way of dealing with this problem.

Struts2 comes with a very useful class com.opensymphony.xwork2.ActionSupport. We just have to extend our LoginAction class with this class and directly use methods such as getText(), addActionErrors() etc. Thus we will extend the LoginAction class with ActionSupport class and add the logic for error reporting into it. The final code in LoginAction must look like:

package net.viralpatel.struts2;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	private String username;
	private String password;

	public String execute() {

		if (this.username.equals("admin")
				&& this.password.equals("admin123")) {
			return "success";
		} else {
			addActionError(getText("error.login"));
			return "error";
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}

And that’s it. Our first Hello World Struts2 Application is now ready.

That’s All Folks

Execute the application in Eclipse and run it in your favorite browser.
Login page
struts2-application-login-page

Welcome page
struts2-welcome-page

Login page with error
struts2-login-page-error

Download Source Code

Click here to download Source Code without JAR files (9KB).

Moving On

Now that we have created our first webapp using Struts2 framework, we know how the request flows in Struts2. We also know the use of struts.xml and properties file. In this application we implemented a preliminary form of validation. In next part we will learn more about Validation Framework in Struts2 and implement it in our example.

If you read this far, you should follow me on twitter here.



161 Comments

  • mabb0512 wrote on 20 June, 2011, 4:06

    I followed this tutorial and I’m getting the following error:

    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at org.springframework.web.context.support.ServletContextResource.getInputStreamWhy is it asking for a applicationContext.xml??? Please help..

    • Sandeep Pant wrote on 16 January, 2012, 21:28

      While copying jar files to your lib folder just copy only following jar files..
      commons-logging-1.0.4.jar
      freemarker-2.3.8.jar
      ognl-2.6.11.jar
      struts2-core-2.0.12.jar
      xwork-2.0.6.jar
      Don’t copy entire lib folder that you have downloaded from Apache Struts2 JAR files

  • saurabh neekhra wrote on 21 June, 2011, 10:50

    I am getting this error :

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.tiles.impl.CannotRenderException: ServletException including path ‘/BaseLayout.jsp’.
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:680)
    org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:633)

  • Raji wrote on 25 June, 2011, 12:20

    Thanks a lot for such a descriptive error free tutorial.. i have tried it and it worked properly in the first attempt itself…

  • Jaseer wrote on 8 July, 2011, 14:30

    Was this page hacked yesterday. I was following this tutorial and yesterday when i opened up this page, it gave a page with a message and then redirected to youtube.
    Thanks for bringing back the page. Its unfortunate there are losers out there who have nothing better to do than hack a tutorial page.
    Your tutorial is quite good. Thanks for the effort and keep up the good work

    • Viral Patel wrote on 8 July, 2011, 16:19

      @Jaseer – Yes unfortunately the blog was hacked. We are back again after certain precautionary measures :-)

  • naveen wrote on 19 July, 2011, 10:31

    i am beginer in struts2 so i am not unable to execute your example in eclipse
    i found 404 error , how would we predict.

    • Viral Patel wrote on 20 July, 2011, 23:54

      @naveen – Check the server logs and see if you getting any other exception. Generally this error is due to problem in dependencies (correct jar files and version). Check the server logs.

  • syed wrote on 27 July, 2011, 16:05

    these errors comming when i execute this one

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException: /Login.jsp(4,1) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=ISO-8859-1, new: text/html; charset=UTF-8)
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
    org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:132)
    org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:608)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
    org.apache.jasper.compiler.Validator.validateDirectives(Validator.java:1723)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:182)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:415)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.

  • niz wrote on 4 September, 2011, 16:50

    Hi,

    I have followed these steps and it actually worked. but when i try to run it again im getting following problem.

    HTTP Status 404 – /StrutsHelloWorld/

    ——————————————————————————–

    type Status report

    message /StrutsHelloWorld/

    description The requested resource (/StrutsHelloWorld/) is not available.

    ——————————————————————————–

    Apache Tomcat/6.0.20

    Please help.

  • Neha wrote on 27 September, 2011, 17:45

    Hi,

    I am unable to get the key values from ApplicationResource file.Not sure what is the probelm
    could u pls help ?

    Thanks,
    Neha

  • Mitch wrote on 21 October, 2011, 18:27

    I am new to Struts2, and tried to make this tutorial work using MyEclipse 9.1. I set up a Web app, then added Struts2 to it. I am also using Maven2, which I added via the wizard.

    I am getting a compile error in Login.jsp for line2, which is the taglib for /struts-tags.

    I am missing something basic as far as how the Eclipse setup with Maven differs from how the tutorial is laid out. For example, under WebRoot – WEB-INF is an empty directory ‘lib’ and the files struts-bean.tld, struts-config.xml, struts-html,tld, struts-logic.tld, struts-nested.tld, struts-tiles.tld, validator-rules.xml, and web.xml.

    Any help for a Java Web newbie would be greatly appreciated.

    Thanks,

    mitch

  • Sunny wrote on 25 October, 2011, 17:53

    Hello, I read your Struts 2 post and I like it. I already know Struts1. In that I follow same method. Then,my question is that, What is the difference between Struts1 and Struts 2 ?

  • saikumar wrote on 28 October, 2011, 12:15

    please tell me what are the jar files we are using in struts 2 application….. kindly tell me total jar files …list…thanking you …

    –sai—

  • Mark wrote on 11 November, 2011, 16:05

    Nice example. What is missing is the session management.
    You can directly go to /Welcome.jsp without being logged in.

  • Siddharth Singh wrote on 14 November, 2011, 13:56

    Thanks a lot…

  • JP wrote on 15 November, 2011, 18:07

    Thank you very much for this.
    I have never used struts before, and have had little / no success with other tutorials I have tried.

    This one was great, well explained and concise.
    Great work!

  • ps wrote on 28 November, 2011, 15:01

    one of the best for a beginner.thanx for the help

  • Shyamal Tarafdar wrote on 28 November, 2011, 22:17

    Thanks for this article.Through this article i entered to struts2 world.

  • Ramkumar wrote on 5 December, 2011, 12:37

    Hi,
    Where should I place my tld files in the above example

    • Ravi wrote on 20 December, 2011, 17:16

      You dont have to worry about the tld files in this above example
      it will be automatically taken..

  • williams wrote on 7 December, 2011, 2:17

    is very good to learn from this link because it satisfies all the requirement which is needed by java leaerners

  • pavitra wrote on 15 December, 2011, 11:54

    Thanks a lot!!!
    Finally a good tutorial…

  • Everett Zhou wrote on 21 December, 2011, 19:30

    Thank you for the great tutorial. It works fine with me. But I got the warning for this line:

    The warning is: Package default extends undefined package struts-default.
    I believe I have the same package structures and my IDE is MyEclipse.

  • Nikhil wrote on 22 December, 2011, 20:24

    Hi Viral, Its nice blog to start with. I am getting following error.

    I am using Eclipse Indigo, Tomcat 7.0.23, Struts 2.3.1.

    Please let me know if you have any solution. Regards.

    HTTP Status 500 –
    ——————————————————————————–
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
    com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)

    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.23 logs.
    ——————————————————————————–
    Apache Tomcat/7.0.23

    • Arun wrote on 7 January, 2012, 17:28

      Nikhil , I am facing the same problem you have mentioned, did you find any solution, pls let me know, you can mail me in arunknl@gmail.com

  • Nikhil wrote on 22 December, 2011, 20:30

    Sorry I forgot to mention that, Application runs fine and show the Login page, but I cant see the “Login” written on the button on Login.jsp page, first. And second, when I click on the button, in both the cases i.e. wrong credentials and correct credentials, I am getting the above mentioned error message i.e. HTTP Status 500 –.

  • Pete wrote on 26 December, 2011, 21:45

    Thanks nice tutorial.

    I had to include 9 libs from the struts framework to make it work: io, fileupload, javassist and common lang.

  • Ashish wrote on 28 December, 2011, 0:42

    nice tutorial

  • Prabath wrote on 30 December, 2011, 14:07

    This is a nice tutorial, But I got below Issue.

    java.lang.NoSuchMethodException: net.viralpatel.struts2.LoginAction.authenticate()

    Please help me to sort out this issue.

    Regards
    Prabath

    • Ashish wrote on 31 December, 2011, 20:39

      coz ur class LoginAction do not have any method named authenticate() and u are trying to call such method.
      Check the method name.
      Try exactly the same approach as described above.It will work fine!

      Thanks,
      Ashish

      • Prabath wrote on 2 January, 2012, 13:40

        Thanks for your reply Ashish

        I have not created such a method. I just deployed the sources attached to this article. But such a method is defined in struts.xml. Pls help me to sort out out this issue

        Thanks
        Prabath

        • Ashish wrote on 6 January, 2012, 23:29

          Buddy if u have done exactly the same as mentioned in this article, then u just need to remove “method=”authenticate” only this line from
          which is present in the Struts.xml.
          Cos the thing is execute() method is the default method which will get executed, and u have mentioned explicitly “authenticate” even tough the method in the Action Class is execute.
          Else, u can make the method in the Action Class as authenticate.
          Anything will work for sure:) …
          Lemme know if this resolve ur problem …

          Thanks,
          Ashish

  • Ijaz wrote on 3 January, 2012, 16:17

    please write tutorial about Struts with hibernate and Spring .. thanks alot..

  • Arun wrote on 5 January, 2012, 22:29

    Hi Viral Patel,

    Thanks a lot for building this wonderful tutorial – great work……

    I am new to struts2, i tried the above example, I am able to get the login page succesfully running
    when i enter the user id and pwd I get the below error

    java.lang.NullPointerException
    	org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
    	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
    

    And in the server startup I get warnigns
    WARNING: No configuration found for the specified action: ‘login.action’ in namespace: ‘/’. Form action defaulting to ‘action’ attribute’s literal value.

    Note: I verified struts.xml
    Welcome.jsp
    Login.jsp
    Login.jsp

    Pls let me know where i am missing out…. thnx in advance…

    Regards
    Arun

  • Ansh wrote on 7 January, 2012, 17:34

    After clicking “run as server” it is showing an error “main class not found.Program will exit.” Any Help?

  • Ansh wrote on 7 January, 2012, 18:01

    HTTP Status 404 – /StrutsHelloWorld/

    ——————————————————————————–

    type Status report

    message /StrutsHelloWorld/

    description The requested resource (/StrutsHelloWorld/) is not available.

    ——————————————————————————–

    Apache Tomcat/6.0.14

    um, last problem sorted out now this one . any help?? I have set the workspace as d:\project\workspace

  • Ansh wrote on 9 January, 2012, 22:08

    I am getting 404 error
    If I remove the web.xml file and rename login.jsp as index.jsp than porject is excuting and generating error list related to absence of filter dispatcher
    but with web.xml file in WEB-INF when I run the project it says resource not found 404 error
    um what should I do ?
    I am using struts 2.3.1 and tomcat 6

  • ashu wrote on 17 January, 2012, 20:18

    Thanks for the nice article. I am new to struts. and I m upgrading struts to 1.3.10., I am getting below message on apache console

    INFO: Initializing composable request processor for module prefix ”
    Jan 17, 2012 8:04:34 PM org.apache.struts.chain.commands.servlet.CreateAction createAction
    INFO: Initialize action of type: com.technia.ncm.actions.CheckCodeAction

    Cld you please help on this.

  • Bhaskar wrote on 24 January, 2012, 13:04

    Hi, i am trying to run my first project in struts, but its not running.
    Everytime i get the 404 error. I have the welcome page in my web.xml file. But still not working

    • Ashish wrote on 26 January, 2012, 11:26

      Hi Bhaskar,
      the 404 error comes when the server is running fine, but the code is not able to find the page which was requested.
      If this error you are getting @ the startup then there is some problem with your login.jsp page.
      Have a check if in your web.xml page the is login.jsp or in that case the page which u want to get called.
      Thanks,
      Ashish

  • shirisha wrote on 25 January, 2012, 14:27

    hi,
    i am not getting any errors but my programming is not running

    • Ashish wrote on 26 January, 2012, 11:18

      This shouldn’t happen if you had done exactly the same as mentioned in this tutorial. please check if your tomacat server is in running mode/ configured properly

  • Raju wrote on 26 January, 2012, 18:53

    I am getting this error
    SEVERE: Exception starting filter struts2
    java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
    Jan 26, 2012 6:46:21 PM org.apache.catalina.core.StandardContext start
    INFO: Server startup in 734 ms

    • Viral Patel wrote on 27 January, 2012, 0:39

      Please check if all the required JAR files are present in WEB-INF/lib folder and the same added to project’s classpath.

  • SiDDHi wrote on 1 February, 2012, 12:15

    Hi guys.. I got ‘resource not found error’.. wat i do..

  • Anoop wrote on 3 February, 2012, 12:26

    I am getting this error ,
    “There is no Action mapped for namespace / and action name add”.

  • Fran wrote on 4 February, 2012, 17:51

    Hi all!
    I made the tutorial but when I run the application ( http://localhost:8080/StrutsHelloWorld/ ) I see the message “The requested resource (/StrutsHelloWorld/) is not available.”:

    Estado HTTP 404 – /StrutsHelloWorld/
    ——————————————————————————–
    type Informe de estado
    mensaje /StrutsHelloWorld/
    descripción El recurso requerido (/StrutsHelloWorld/) no está disponible.
    ——————————————————————————–
    Apache Tomcat/7.0.25

    I’m ussing:
    struts-2.3.1.2
    apache-tomcat-7.0.25

    does anyone know fix this problem?
    Thanks,

  • RajeshR wrote on 5 February, 2012, 17:41

    Nice article. Well explained with simplicity.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Copyright © 2012 ViralPatel.net. All rights reserved.