struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas CORNET <tho...@cornet.name>
Subject Modules
Date Sun, 02 Mar 2003 23:27:59 GMT


         Hi all :)

     I hope someone will have a clue for me, because I'm fighting against 
Struts modules for a couple of weeks now, and nothing works.

     According to the few tutorials available on Net about struts' modules, 
all is very easy. Here is what I've understand :

a) create a subdir in your application named for example 'guestbook'
b) declare in your web.xml another init parameter such as :

     <init-param>
         <param-name>config/guestbook</param-name>
         <param-value>/WEB-INF/struts-config-guestbook.xml</param-value>
     </init-param>

c) create the struts-config-guestbook.xml and fill it with forms, actions, ...
d) now, every page in the 'guestbook' directory will access first the 
struts-config-guestbook.xml to search for actions, forms, forwards ....

     If I'm wrong at this point, explain me plz what I missed.


     I did every step of these tutorials and each time, it says (page URL 
is http://localhost/aejase/guestbook/guestbook.jsp) :

          [ServletException in:/guestbook/tiles/guestbook.jsp] Cannot 
retrieve mapping for action /addguestbook'


     What i did next is to create a page 'test.jsp' in my 'guestbook' 
directory. I've searched in the Form tag java source to see how it's 
reaching the action's properties, and I've used the same methods and 
classes to display the current module's properties of test.jsp. Here is the 
JSP code :

------------------------------

// part 1

org.apache.struts.config.ModuleConfig cfg = 
org.apache.struts.util.RequestUtils.getModuleConfig(pageContext);
org.apache.struts.config.ActionConfig[] actions = cfg.findActionConfigs();

out.println("URL : " + 
org.apache.struts.util.RequestUtils.requestURL(request).toString() + "<br>");

out.println("current module's prefix : >" + cfg.getPrefix() + "<<br>");
out.println("current module's number of actions : " + actions.length + "<br>");

for (int i = 0; i < actions.length; i++)
{
out.println("action's name #" + (i+1) + " : " + actions[i].getName() + "<br>");
out.println("action's path #" + (i+1) + " : " + actions[i].getPath() + "<br>");
out.println("action's prefix #" + (i+1) + " : " + actions[i].getPrefix() + 
"<br>");
}

// part 2

String[] mc = 
org.apache.struts.util.RequestUtils.getModulePrefixes(application);

for (int i = 0; i < mc.length; i++)
out.println("<br> application's modules prefix -> " + mc[i]);

// part 3

out.println("<p>getModuleName(request, application) : " + 
org.apache.struts.util.RequestUtils.getModuleName(request, application));


----------------------------------

a) Output of part 1:

=======================

URL : http://localhost/aejase/guestbook/test.jsp
current module's prefix : ><
current module's number of actions : 1
action's name #1 : quicksearchForm
action's path #1 : /quicksearch
action's prefix #1 : null

========================

My conclusion : the module used by my test page is the default one 
(no-prefix). To prove this, I've listed all the actions of the module, and 
the result is the actions of my struts-config.xml file. So I can't call the 
action of my struts-config-guestbook.xml file. Question : why doesn't 
struts use the guestbook module ? Did I do something wrong ??


b) Output of part 2 is :

==========================

application's modules prefix -> /quicksearch
application's modules prefix -> /guestbook

===========================

It lists all the modules prefix available for the application. All is 
working file, the webapp knows all my modules.


c) Output of part 3 is :

===========================

getModuleName(request, application) : /guestbook

===========================

Just a try, using RequestUtils.getModuleName(request, application)... It 
seems to work well, i don't understand why, when i've seen output 1.



I don't seem to reach the solution, and i hope some higher intelligence can 
help me. Thanks in advance for all anwer :)



                                                 Thomas

Configuration :

Windows XP Pro
Tomcat 4.1.18 under Apache Tomcat 2.0.44 with JK2 connector
Struts 1.1-rc1
J2DSK 1.4.1_01


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message