Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Multiple dispatcher servlets

  1. #1
    Join Date
    Sep 2004
    Posts
    9

    Default Multiple dispatcher servlets

    I am trying to have two seperate dispatcher servlets (webstore-servlet.xml and console-servlet.xml), one for URLs of pattern /shop/*.do and the other for /console/*.do in the same web application.

    I tried the following in web.xml:
    Code:
      <servlet-mapping>
        <servlet-name>webstore</servlet-name>
        <url-pattern>/shop/*</url-pattern>
      </servlet-mapping>
      
      <servlet-mapping>
        <servlet-name>console</servlet-name>
        <url-pattern>/console/*</url-pattern>
      </servlet-mapping>
    However I get "The requested resource (/csc8408/shop/viewCatalog.do) is not available." I tried a number of other things but still it would not work.

    How should I be configuring this?

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Can you post more of your, specifically the Spring context configuration and the code for your controller that handles that page?

    Rob

  3. #3
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    How does the url handler mapping look like. If you mention /shop/* in youir web.xml, you shouldn't mention the /shop again in your handlermapping. just mentioned /viewCatalog.do in the mapping (instead of /shop/viewCatalog.do).

    Alef

    p.s. Why are you trying to make your application look like a Struts app ;-).

  4. #4
    Join Date
    Sep 2004
    Posts
    9

    Default

    Thanks, I tried "viewCatalog.do" but not "/viewCatalog.do".

    What extension should I be using? (htm?)

  5. #5
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    What extension should I be using? (htm?)
    Whatever you like. I was just kidding about Struts.

    I wouldn't suggest to use html or htm. If you ever need to put any static content on an Apache server linked to Tomcat for instance through mod_jk you'll run into problems.

    I usually use things like .edit, ..view, etcetera.

    Alef

  6. #6
    Join Date
    Oct 2008
    Location
    Singapore
    Posts
    5

    Question Similar problem here

    Hi, I'm facing the similar problem, I put two servlets taxi_booking and taxi_admin

    Code:
    <servlet>
    		<servlet-name>taxi_booking</servlet-name>
    		<servlet-class>
    			org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    	<servlet>
    		<servlet-name>taxi_admin</servlet-name>
    		<servlet-class>
    			org.springframework.web.servlet.DispatcherServlet
    		</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>	
    	
    	<servlet-mapping>
    		<servlet-name>taxi_booking</servlet-name>
    		<url-pattern>/app/*</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>taxi_admin</servlet-name>
    		<url-pattern>/admin/*.do</url-pattern>
    	</servlet-mapping>
    I provided two xmls: taxi_booking-servlet.xml and taxi_admin-servlet.xml . The first servlet /app is working, but the second one is not working at all. Debugging with Eclipse also gives me a hint that the taxi_admin-servlet.xml is not processed at all.

    Is there anything I missed out?
    Thank you so much for the help!
    Robert

  7. #7
    Join Date
    Mar 2006
    Location
    Bangalore, India
    Posts
    242

    Default

    Hi,

    Is this a good practice or a recommended practice to have multiple dispatcher servlets,

    What are the advantages of having multiple dispatcher servlets? will the dispatcher servlet not initialize another spring container incase of 2.3 servlet containers
    Sami

  8. #8
    Join Date
    Oct 2008
    Location
    Singapore
    Posts
    5

    Default

    I was trying to separate the module configuration. I'm adding another module to an existing application. And I'd like to use a different kind of configuration (annotation instead of pure xml).

    Is it really a problem to have 2 dispatcher servlet?

    Thanks!

  9. #9
    Join Date
    Oct 2006
    Posts
    228

    Default

    From the DispatcherServlet javadoc:

    A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by ContextLoaderListener, if any, will be shared.
    Have you checked the application server logs for any errors or warnings during startup?

    Also, not sure what the affect of having the load-on-startup set as 2 for both servlets, perhaps giving these separate values would help.

    Chris

  10. #10
    Join Date
    Oct 2008
    Location
    Singapore
    Posts
    5

    Default

    Thanks Chris, I managed to use 2 dispatcher servlets. I tried to combine, but it messed up module. The load-on-startup is not a problem. It's on some other configuration.
    Thanks anyway!
    Check out Reason-4-Smile Weblog for some smile

Similar Threads

  1. Replies: 2
    Last Post: Apr 28th, 2005, 09:37 AM
  2. Multiple Axis servlets
    By dan.baumann in forum Remoting
    Replies: 1
    Last Post: Apr 21st, 2005, 03:19 AM
  3. Replies: 1
    Last Post: Mar 9th, 2005, 03:52 PM
  4. Replies: 1
    Last Post: Feb 25th, 2005, 07:12 AM
  5. Multiple Pages
    By afida in forum Swing
    Replies: 12
    Last Post: Feb 16th, 2005, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •