Announcement Announcement Module
Collapse
No announcement yet.
Multiple dispatcher servlets Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Can you post more of your, specifically the Spring context configuration and the code for your controller that handles that page?

    Rob

    Comment


    • #3
      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 ;-).

      Comment


      • #4
        Thanks, I tried "viewCatalog.do" but not "/viewCatalog.do".

        What extension should I be using? (htm?)

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment


              • #8
                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!

                Comment


                • #9
                  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

                  Comment


                  • #10
                    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!

                    Comment


                    • #11
                      affect the js and css?

                      this form to work with spring mvc, does it affect the get of .js and css files?; for example:

                      <link rel="stylesheet" type="text/css" href="<c:url value="/file/styles.css" />">

                      or

                      <link rel="stylesheet" type="text/css" href="/file/styles.css">
                      .
                      <script type="text/javascript" src="<c:url value="/file/file.js" />"> </script>

                      or

                      <script type="text/javascript" src="/file/file.js"> </script>

                      because the jsp doesn't recognize it.

                      Comment


                      • #12
                        Hello roberthenru,
                        Please let me know what did you fix ? I have the same issue.
                        Thanks
                        Rgs
                        Rahul

                        Comment


                        • #13
                          I'm also trying to setup two DispatcherServlets in my web.xml and I run into the same issue.
                          Could you share your solution?

                          Thanks,
                          Yannis

                          Comment

                          Working...
                          X