• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Modules - Help?

 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you tried DispatchAction? there you can use single servlet for different actions.. I m not sure guys.. please explain me clearly..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic