0

I'm trying to use a bean to show predefined messages, I have created the following files, but it runs into following error, when I type <me the auto code generator does not show <message - resources> tag!

org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

Note: The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

struts.xml

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts-config> <!-- Configuration for the default package. --> <message-resources parameter="com/myapp/struts/messages"/> <package name="default" extends="struts-default"> <result-types> <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/> </result-types> <action name="register"> <result type="tiles">register</result> </action> </package> </struts-config> 

register.jsp:

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <div id="Header"> <bean:message key="welcome.loggedin"/> </div> 

messages.properties:

# -- welcome -- welcome.loggedin=You are logged in. welcome.heading=Struts Applications in Netbeans! welcome.message=It's easy to create Struts applications with NetBeans. 

I suppose the problem is with my jar files

commons-digester-1.8.1.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-lang-2.1.jar commons-logging-1.1.jar displaytag-1.2.jar displaytag-export-poi-1.2.jar displaytag-portlet-1.2.jar freemarker-2.3.13.jar jdom-1.1.jar jstl-1.2.jar junit-3.8.1.jar ognl-2.6.11.jar pagertag.jar sqlite-jdbc-3.7.2.jar struts2-convention-plugin-2.1.6.jar struts2-core-2.1.6.jar struts2-dojo-plugin-2.1.2.jar struts2-tiles-plugin-2.1.6.jar tiles-api-2.1.2.jar tiles-compat-2.1.2.jar tiles-core-2.1.2.jar tiles-jsp-2.1.2.jar tiles-servlet-2.1.2.jar struts-taglib-1.3.10.jar xwork-2.1.2.jar 

2 Answers 2

2

The <bean:message key= tag is a Struts1 tag and in Struts2 it's replaced with <s:text name=. Unless you don't have enough reason to run both frameworks you should not use Struts1 tags.

Sign up to request clarification or add additional context in comments.

Comments

1

You're using Struts 1 tags in a Struts 2 application. Don't. Struts 1 and Struts 2 are two completely different web frameworks.

Here's the Struts2 documentation page about i18n.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.