aspose file tools*
The moose likes Struts and the fly likes Multiple Modules - Help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple Modules - Help?" Watch "Multiple Modules - Help?" New topic
Author

Multiple Modules - Help?

Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I have a Struts web application that needs to have different Actions and views for different types of consumers (say, "user" and "admin"). Most resources are the same, but there are instances where there are differences (for example, there are distinct login pages). I need to be able to track a user through the application so that if they time out (session expires), they get routed back to the correct login page.

I tried configuring Struts 1.1 with multiple modules in web.xml, each handling a different url-pattern ("/users/*" and "/admin/*"). I specified differently-named Struts ActionServlets for each mapped url-pattern, each with a different Struts config.xml file. Yet I seem to get routed to one servlet consistently, regardless of whether I use "http://localhost/myApp/users/login" or "http://localhost/myApp/admin/login". I always end up with the view that's defined by the servlet that should only be handling "admin" requests, even when the request is for the "users" servlet.

Any idea why this may be happening? I am using Struts 1.1 on Tomcat 5.0.

Here's a copy of my web.xml file:

<web-app>

<servlet>
<servlet-name>testApp</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>testAdminApp</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-borr-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>testApp</servlet-name>
<url-pattern>/users/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>testAdminApp</servlet-name>
<url-pattern>/admin/*</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>



</web-app>


Todd Farmer
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
I think it's quite normal to root you to the same servlet as long as you declared the same one to be used for both mappings.

./pope


blog - InfoQ.com
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I'm not sure I understand what is meant when you say I declared the same one for both mappings. I'm under the impression that my <servlet-mapping> tags specify different paths for different named servlets (although the two servlets are the same class, is that what you meant?):

<servlet-mapping>
<servlet-name>testApp</servlet-name>
<url-pattern>/users/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>testAdminApp</servlet-name>
<url-pattern>/admin/*</url-pattern>
</servlet-mapping>

I just can't quite get my head around this one. Any additional help would be appreciated.

Thanks!

Todd Farmer
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
I have just noticed this:



Maybe you can try for the beginning to use another servlet and then find otu what is wrong with the context.

./pope
Prakash Mani - Attur
Ranch Hand

Joined: Oct 08, 2009
Posts: 100
have you tried DispatchAction? there you can use single servlet for different actions.. I m not sure guys.. please explain me clearly..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Multiple Modules - Help?