Tutorial: Creating Struts application in Eclipse

In this tutorial we will create a hello world Struts application in Eclipse editor. First let us see what are the tools required to create our hello world Struts application.

  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 Struts JAR files:(download). Following are the list of JAR files required for this application.
    • struts.jar
    • common-logging.jar
    • common-beanutils.jar
    • common-collections.jar
    • common-digester.jar

We will implement a web application using Struts framework which will have a login screen. Once the user is authenticated, (s)he will be redirected to a welcome page.

Let us start with our first struts based web application.

Open Eclipse and goto File -> New -> Project and select Dynamic Web Project in the New Project wizard screen.

After selecting Dynamic Web Project, press Next.

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.

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

Next step is to create a servlet entry in web.xml which points to org.apache.struts.action.ActionServlet class of struts framework. Open web.xml file which is there under WEB-INF folder and copy paste following code.

<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>

Here we have mapped url *.do with the ActionServlet, hence all the requests from *.do url will be routed to ActionServlet; which will handle the flow of Struts after that.

We will create package strutcures for your project source. Here we will create two packages, one for Action classes (net.viralpatel.struts.helloworld.action) and other for Form  beans(net.viralpatel.struts.helloworld.action).

Also create a class LoginForm in net.viralpatel.struts.helloworld.action with following content.


package net.viralpatel.struts.helloworld.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {

	private String userName;
	private String password;

	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors actionErrors = new ActionErrors();

		if(userName == null || userName.trim().equals("")) {
			actionErrors.add("userName", new ActionMessage("error.username"));
		}
		try {
		if(password == null || password.trim().equals("")) {
			actionErrors.add("password", new ActionMessage("error.password"));
		}
		}catch(Exception e) {
			e.printStackTrace();
		}
		return actionErrors ;
	}

	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;
	}
}

LoginForm is a bean class which extends ActionForm class of struts framework. This class will have the string properties like userName and password and their getter and setter methods. This class will act as a bean and will help in carrying values too and fro from JSP to Action class.
Let us create an Action class that will handle the request and will process the authentication. Create a class named LoginAction in net.viralpatel.struts.helloworld.action package. Copy paste following code in LoginAction class.

package net.viralpatel.struts.helloworld.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.viralpatel.struts.helloworld.form.LoginForm;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LoginAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		String target = null;
		LoginForm loginForm = (LoginForm)form; 

		if(loginForm.getUserName().equals("admin")
				&& loginForm.getPassword().equals("admin123")) {
			target = "success";
			request.setAttribute("message", loginForm.getPassword());
		}
		else {
			target = "failure";
		}

		return mapping.findForward(target);
	}
}

In action class, we have a method called execute() which will be called by struts framework when this action will gets called. The parameter passed to this method are ActionMapping, ActionForm, HttpServletRequest and HttpServletResponse. In execute() method we check if username equals admin and password is equal to admin123, user will be redirected to Welcome page. If username and password are not proper, then user will be redirected to login page again.

We will use the internationalization (i18n) support of struts to display text on our pages. Hence we will create a MessagesResources properties file which will contain all our text data. Create a folder resource under src (Right click on src and select New -> Source Folder). Now create a text file called MessageResource.properties under resources folder.

Copy the following content in your Upadate:struts-config.xml MessageResource.properties file.

label.username = Login Detail
label.password = Password
label.welcome = Welcome

error.username =Username is not entered.

Create two JSP files, index.jsp and welcome.jsp with the following content in your WebContent folder.

index.jsp

<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Login page | Hello World Struts application in Eclipse</title>
	</head>
	<body>
	<h1>Login</h1>
	<html:form action="login">
		 <bean:message key="label.username" />
		 <html:text property="userName"></html:text>
		 <html:errors property="userName" />
		 <br/>
		 <bean:message key="label.password"/>
		<html:password property="password"></html:password>
		 <html:errors property="password"/>
		<html:submit/>
		<html:reset/>
	</html:form>
	</body>
</html>

welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Welcome page | Hello World Struts application in Eclipse</title>
	</head>
	<body>
	<%
		String message = (String)request.getAttribute("message");
	%>
		<h1>Welcome <%= message %></h1>

	</body>
</html>

Now create a file called struts-config.xml in WEB-INF folder. Also note that in web.xml file we have passed an argument with name config to ActionServlet class with value /WEB-INF/struts-config.xml.

Following will be the content of struts-config.xml file:

<?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>
	<form-beans>
		<form-bean name="LoginForm"
			type="net.viralpatel.struts.helloworld.form.LoginForm" />
	</form-beans>

	<global-exceptions>
	</global-exceptions>
	<global-forwards></global-forwards>

	<action-mappings>
		<action path="/login" name="LoginForm" validate="true" input="/index.jsp"
			type="net.viralpatel.struts.helloworld.action.LoginAction">
			<forward name="success" path="/Welcome.jsp" />
			<forward name="failure" path="/index.jsp" />
		</action>
	</action-mappings>

	<message-resources parameter="resource.MessageResource"></message-resources>

</struts-config>


And, that’s it :) .. We are done with our application and now its turn to run it. I hope you have already configured Tomcat in eclipse. If not then:

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)

Login Page

Welcome Page


Related Articles


            

44 Comments on “Tutorial: Creating Struts application in Eclipse”

  • Aditi wrote on 4 December, 2008, 19:14

    Thanks Viral,
    The explanation and information is very apt.
    Very useful.

  • Veera wrote on 4 December, 2008, 21:01

    Informative post.

    Here’s a similar tutorial, but for the latest version of struts 2 - Create Struts 2 - Hello World Application

  • Zviki wrote on 5 December, 2008, 2:14

    If you’re (still) doing Struts, you should check out Oracle Workshop for WebLogic. It is the best Struts tool by far, includes many examples and can do much much more than Eclipse WTP. It is not WebLogic specific. And, it’s free.

    Check out my post about it:
    http://blog.zvikico.com/2008/08/the-best-jspstrutsjsf-development-tool-is-now-free.html

  • Viral Patel wrote on 5 December, 2008, 11:45

    @Veera : Nice to see your Struts-2 tutorial. You will see more tutorials on similar line here on viralpatel.net

    @Zviki : Thanks for your comment. Will definitely check Oracle Workshop for WebLogic.

  • tabrez wrote on 9 December, 2008, 14:42

    Nice tutorial, good job :)

    @Zviki I suggest having a look at IntelliJ IDEA’s support for Struts 2, in my opinion it is one of the best. It’s not free, though.

  • chn wrote on 15 December, 2008, 21:38

    hi did anyone try this with WASCE server? iam doing in it and evrything looks fine except that when i clikc on submit it says that the resource/login is not found..

    any ideas pls help

  • kingshri wrote on 25 December, 2008, 13:54

    I am getting this exception while deploying this …. Can anyone help?

    HTTP Status 500 -

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

    type Exception report

    message

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

    exception

    org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause

    javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:91)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause

    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
    org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
    org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
    org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:107)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • teena wrote on 30 December, 2008, 17:41

    its very useful for beginners

  • mayank wrote on 7 January, 2009, 18:14

    i am getting this exception ..

    HTTP Status 500 -

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

    type Exception report

    message

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

    exception

    org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 12

    9:
    10: Login
    11:
    12:
    13:
    14:
    15:

    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause

    javax.servlet.ServletException: javax.servlet.jsp.JspException: Missing message for key “label.username”
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:96)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause

    javax.servlet.jsp.JspException: Missing message for key “label.username”
    org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:233)
    org.apache.jsp.index_jsp._jspx_meth_bean_005fmessage_005f0(index_jsp.java:174)
    org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:118)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

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

    many thanks
    mayank

  • Vivek wrote on 19 January, 2009, 11:24

    Copy the following content in your struts-config.xml file.

    label.username = Login Detail
    label.password = Password
    label.welcome = Welcome
    error.username =Username is not entered.

    did u mean that paste the above content in MessageResource.properties file? or struts-config.xml file?

  • Viral wrote on 19 January, 2009, 12:05

    Thanks Vivek,
    I have updated the error in post.
    You need to copy this in MessageResource.properties file.

    Thanks again.

  • yogita wrote on 25 January, 2009, 19:37

    Hi
    I am getting following error please help…
    SEVERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
    at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:712)
    at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:500)
    at org.apache.jsp.index_jsp._jspx_meth_html_form_0(org.apache.jsp.index_jsp:132)
    at org.apache.jsp.index_jsp._jspx_meth_html_html_0(org.apache.jsp.index_jsp:108)
    at org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:75)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

  • Jwalant wrote on 1 February, 2009, 12:27

    Hi,

    I am getting Error 404–Not Found From RFC 2068 Hypertext Transfer Protocol — HTTP/1.1:
    10.4.5 404 Not Found . I have double checked web.xml and struts-config.xml. I would appreicate, if anyone can help me.

  • gribo wrote on 5 February, 2009, 18:17

    You should have take the time to make this tutorial with the latest version of struts 1 : v1.3.10
    The version 1.2, on which is based this tutorial, has been released for more than 4 years ! The branch 1.3 which split struts.jar into multiple modules has been release in two years !

  • Sample wrote on 11 February, 2009, 4:58

    Excellent Material for the Beginners.
    Follow the steps carefully, it should definitely work.

    Thanks
    Sample

  • FrEE wrote on 17 February, 2009, 12:54

    Hi,

    There is anice tutorial on how to use Struts2, a basic example at

    http://www.interview-questions-tips-forum.net/index.php/Apache-Struts/Struts2-example-tutorial/My-First-example-using-Apache-Struts2

  • jimish wrote on 20 February, 2009, 16:17

    hai,,this ,,gr8,,,,help to intoduce the struts application

  • Jessiee wrote on 21 February, 2009, 19:17

    I m not able to find jar files u mentioned above.Can u provide me the exact path..

  • Karthic R Raghupathi wrote on 23 February, 2009, 19:43

    Greetings!

    I found your post very educating. This is the first sample struts application I created using eclipse.

    However, I kept getting the error saying the message was not found in the key bundle.

    I tried many things but I got the same error. Finally I modified the entry in the struts-config.xml to
    from what you mentioned. It did the trick.

    I’m using struts 1.3, jdk 6 and eclipse ganymede.. hope that helps.

  • Baran wrote on 2 March, 2009, 14:20

    Hello There,

    I am fairly new to Struts, I was wondering if anyone can post or preferably mail me some materila about how to handle database connectivity in Struts. I am working on JNDI but I guess this won\\\’t be helpful if I have a shared apache tomcat server as that won\\\’t let me access the server.xml file.

    my id is baran.khan @ gmail.com

  • Payal wrote on 19 March, 2009, 10:49

    I am preety new to struts. I want to know how to remove the error Missing message for key \"label.username\"? I have created a package name resource in src and created a file in it with the name MessageResource.properties. What changes i need to make in my struts-config.xml?

  • Viral Patel wrote on 19 March, 2009, 11:20

    Hi Payal,
    I am not sure if I got your problem. What I understand is that you want to remove the error messages generated from keys that are missing in your bundle MessageResource file. If this is the case then you can use null attribute in <message-resources> tag in struts-config.xml file.

    
    

    null attribute will control the messages, If true, references to non existing messages results in null and If false, references to non existing messages result in warning message like
    ???KeyName???
    Hope this will solve your query.

  • Davinchi wrote on 19 March, 2009, 11:31

    Hey thanks for this great tut!!

    But, I was having the same error “Missing message for key “label.username” and I moved the file MessageResource to the folder WEB-INF->classes->resource. That did the trick.

    Can you explain why tis happened? Thanks again mate!

  • Viral Patel wrote on 19 March, 2009, 12:36

    While providing the parameter attribute in <message-resource> tag we provide it as parameter=”resource.MessageResource”. Thus in this case, struts expects the MessageResource.properties file under resource folder. But if you have provided parameter=”MessageResource” then that means your MessageResource properties file is directly under classes folder.

  • grace wrote on 23 March, 2009, 8:20

    Could anyone help me to solve the following error? I have checked the struts-config and web.xml . But I cannot find the error.please…
    ,Grace

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

    javax.servlet.ServletException: Exception creating bean of class net.viralpatel.struts.helloworld.form.LoginForm: {1}
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:91)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    javax.servlet.jsp.JspException: Exception creating bean of class net.viralpatel.struts.helloworld.form.LoginForm: {1}
    org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:563)
    org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:520)
    org.apache.jsp.index_jsp._jspx_meth_html_form_0(index_jsp.java:107)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:81)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Geek wrote on 25 March, 2009, 12:45

    Hi..

    To make this tutorial work:

    1. also add servlet-api.jar.
    2. make sure struts-config.xml is in web-inf folder or the folder u have specified in web.xml
    3. make sure the messageresource file is in web-inf/classes folder.
    4. Change the following line in LoginAction.java from
    request.setAttribute(\"message\", loginForm.getPassword());
    To
    request.setAttribute(\"message\", loginForm.getUserName());

    Kiran

  • sachin wrote on 9 April, 2009, 21:25

    I have done everything as told here.I am using SDE 3.1 and I am getting this exception on runing the application.Can anyone help?

    SEVERE: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: The absolute uri: http://jakarta.apache.org/struts/tags-html cannot be resolved in either web.xml or the jar files deployed with this application
    at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:316)
    at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:147)
    at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
    at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
    at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
    at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
    at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
    at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)

  • Sarwo Edi wrote on 7 May, 2009, 11:28

    help me,
    I am beginner programmer, I got exception in ur tutorial as this

    HTTP Status 500 -

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

    type Exception report

    message

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

    exception

    org.apache.jasper.JasperException: Exception in JSP: /index.jsp:13

    10: <body>
    11: <h1>Login</h1>
    12: <html:form action=\"login\">
    13: <bean:message key=\"label.username\" />
    14: <html:text property=\"userName\"></html:text>
    15: <html:errors property=\"userName\"/>
    16: <br/>

    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

    root cause

    javax.servlet.ServletException: Missing message for key \"label.username\"
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:89)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

    root cause

    javax.servlet.jsp.JspException: Missing message for key \"label.username\"
    org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:233)
    org.apache.jsp.index_jsp._jspx_meth_bean_005fmessage_005f0(index_jsp.java:166)
    org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:110)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

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

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

    Apache Tomcat/5.5.27

    please help me

  • Sarwo Edi wrote on 7 May, 2009, 11:40

    I already copy
    label.username = Login Detail
    label.password = Password
    label.welcome = Welcome
    error.username =Username is not entered.

    to the resource folder, but the exception still occured….

    please help me

  • Sarwo Edi wrote on 7 May, 2009, 16:16

    hey, thanks very much..
    finally I can solve it…

  • Viral Patel wrote on 7 May, 2009, 21:08

    @sarwo edi: nice to see that your problem got solved :) by the way. where was the problem exactly? I guess your properties file was not getting referred properly?

  • Sarwo Edi wrote on 11 May, 2009, 12:31

    yeah, in struts-config, I only type <message-resources parameter=\"MessageResource\" null=\"true\"/>, it make its true…

    btw, any another eclipse tutorial?
    I want to be a good java programmer as you do..

    txh

  • adm wrote on 28 May, 2009, 16:58

    <message-resources parameter=\"resource.MessageResource\"></message-resources>
    should be

    <message-resources parameter=\"MessageResource\"></message-resources>

  • noufendar wrote on 29 May, 2009, 14:43

    Muchas gracias!!! a Viral por el tutorial y también a Davinchi porque dió la solución al mismo problema que tenía yo!!!!

    Davinchi wrote on 19 March, 2009, 11:31
    Hey thanks for this great tut!!

    But, I was having the same error “Missing message for key “label.username” and I moved the file MessageResource to the folder WEB-INF->classes->resource. That did the trick.

    Can you explain why tis happened? Thanks again mate!

  • Pankaj wrote on 5 June, 2009, 10:40

    I have followed ur tutorial

    i am getting error

    VERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
    at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
    at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
    at org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:115)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:88)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:390)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    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:228)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
    at java.lang.Thread.run(Unknown Source)
    Jun 5, 2009 10:43:41 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
    at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
    at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
    at org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:115)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:88)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:390)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    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:228)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
    at java.lang.Thread.run(Unknown Source)

    can you tell me what can be cause of this.

  • StrutsNewbie wrote on 8 June, 2009, 8:02

    Hi~

    I have modified the line
    <message-resources parameter=\\\"resource.MessageResource\\\"></message-resources>
    to
    <message-resources parameter=\\\"MessageResource\\\"></message-resources>

    And I have followed all the instructions, I am now using Struts 1.3.10, but I got \"HTTP Status 404\" error,

    \"The requested resource (/StrutsHelloWorld/) is not available.\"

    Anyone may help? Thx!

  • StrutsNewbie wrote on 8 June, 2009, 8:07

    More description abt my problem,

    In Eclipse I got the following URI underlined in red!

    \\&quot;&lt;%@taglib uri=\\&quot;http://jakarta.apache.org/struts/tags-html\\&quot; prefix=\\&quot;html\\&quot;%&gt;
    &lt;%@taglib uri=\\&quot;http://jakarta.apache.org/struts/tags-bean\\&quot; prefix=\\&quot;bean\\&quot; %&gt; \\&quot;

    Eclipse says \\&quot;cannot find tag library descriptor\\&quot;

    How should I modify the \\&quot;uri\\&quot;? Thx so much!

  • Sandhya wrote on 12 June, 2009, 10:47

    Can any one help me…..

    type Exception report

    message

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

    exception

    org.apache.jasper.JasperException: Exception creating bean of class com.jamesholmes.minihr.SearchForm under form name searchForm
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

    root cause

    javax.servlet.ServletException: Exception creating bean of class com.jamesholmes.minihr.SearchForm under form name searchForm
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
    org.apache.jsp.search_jsp._jspService(search_jsp.java:230)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

    root cause

    javax.servlet.jsp.JspException: Exception creating bean of class com.jamesholmes.minihr.SearchForm under form name searchForm
    org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:536)
    org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:503)
    org.apache.jsp.search_jsp._jspx_meth_html_005fform_005f0(search_jsp.java:263)
    org.apache.jsp.search_jsp._jspService(search_jsp.java:101)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

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

  • sushma wrote on 18 June, 2009, 23:22

    can anyone help, i got the following exception while executing

    type Exception report

    message

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

    exception

    org.apache.jasper.JasperException: Module ‘null’ not found.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

    root cause

    java.lang.NullPointerException: Module ‘null’ not found.
    org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:743)
    org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:723)
    org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:742)
    org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:417)
    org.apache.jsp.index_jsp._jspx_meth_html_005fform_005f0(index_jsp.java:105)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

Trackbacks

  1. Struts Tiles plugin example in Eclipse | viralpatel.net
  2. Tutorial:Struts Spring framework example in Eclipse | viralpatel.net
  3. Struts File Upload | Struts File Upload Tutorial | Example | File Upload Struts | viralpatel.net
  4. Struts Dispatch Action tutorial,Struts DispatchAction example, DispatchAction tutorial
  5. Struts Validation Framework tutorial & example.Form Validator struts tutorial.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Copyright © 2009 viralpatel.net. All rights reserved.