problem: j2ee, web.xml, about set 2 servlet mapping to the same url

Discussion in 'Java' started by sods, Jan 7, 2006.

  1. sods

    sods Guest

    Hi, all,

    I'm newer for j2ee.

    I find in some /WEB-INF/web.xml,
    there are 2 different servlets mapping to the same url-pattern.

    Doesn't it cause problem?
    I don't know which will process and give response, when request come.
    Whether the two servlet will share the same request obj, or not?

    maybe this is designed for monitor servlet.
    but i can't imagine what happen with two response to a request.


    -Wisdo
     
    sods, Jan 7, 2006
    #1
    1. Advertising

  2. sods

    Chris Smith Guest

    sods <> wrote:
    > I find in some /WEB-INF/web.xml,
    > there are 2 different servlets mapping to the same url-pattern.


    This shouldn't happen. Can you give an example? Maybe there's
    something else really happening there.

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Jan 8, 2006
    #2
    1. Advertising

  3. sods

    Guest

    Re: problem: j2ee, web.xml, about set 2 servlet mapping to the same url

    Can you paste the relevant section of the web.xml file into your post
    so we know exactly what you mean.
     
    , Jan 8, 2006
    #3
  4. sods

    sods Guest

    "Chris Smith" <> дÈëÓʼþ
    news:...
    > sods <> wrote:
    > > I find in some /WEB-INF/web.xml,
    > > there are 2 different servlets mapping to the same url-pattern.

    >
    > This shouldn't happen. Can you give an example? Maybe there's
    > something else really happening there.
    >
    > --
    > www.designacourse.com
    > The Easiest Way To Train Anyone... Anywhere.
    >
    > Chris Smith - Lead Software Developer/Technical Trainer
    > MindIQ Corporation


    of course.

    example:

    <!-- Standard Action Servlet Configuration (with debugging) -->
    <servlet>
    <servlet-name>action</servlet-name>

    <servlet-class>com.xxxx.webapp.common.struts.XXServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>validating</param-name>
    <param-value>@xx.struts.validate.dtd@</param-value>
    </init-param>
    <init-param>
    <param-name>xx.config.root</param-name>
    <param-value>@xx.config.root@</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>action_tmp</servlet-name>

    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>3</param-value>
    </init-param>
    <init-param>
    <param-name>detail</param-name>
    <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
    </servlet>

    <!-- Standard Action Servlet Mapping -->
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>action_tmp</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    any ideas?

    -sods
     
    sods, Jan 9, 2006
    #4
  5. sods

    Chris Smith Guest

    sods <> wrote:
    > <!-- Standard Action Servlet Mapping -->
    > <servlet-mapping>
    > <servlet-name>action</servlet-name>
    > <url-pattern>*.do</url-pattern>
    > </servlet-mapping>
    > <servlet-mapping>
    > <servlet-name>action_tmp</servlet-name>
    > <url-pattern>*.do</url-pattern>
    > </servlet-mapping>


    This is incorrect. I don't see anything in the servlet specification
    that specifically defines how a servlet container will deal with this
    situation, but there are several statements that imply that it should
    choose the first mapping and ignore the second one. However, since that
    isn't stated clearly, if such a behavior were observed for some specific
    implementation, it would be better to remove the second unused mapping
    element to avoid confusion and potential for the web application to
    break on future versions of the servlet container.

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Jan 9, 2006
    #5
  6. sods

    sods Guest

    Re: problem: j2ee, web.xml, about set 2 servlet mapping to the same url

    <> дÈëÓʼþ
    news:...
    > Can you paste the relevant section of the web.xml file into your post
    > so we know exactly what you mean.
    >

    the problem is just
    there are two servlets.

    servlet1:
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>com.xxxx.webapp.common.struts.XXServlet</servlet-class>
    </servlet>

    servlet2:
    <servlet>
    <servlet-name>action_tmp</servlet-name>

    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    </servlet>

    but they mapping to the same url-pattern, like follow.
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>action_tmp</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    when a request /$(CONTEXTPAT)/login.do come, I don't know what happen.

    Chris think it's incorrect according to the J2EE Specification, and
    dangerous to common usage.

    -sods
     
    sods, Jan 9, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Albretch
    Replies:
    2
    Views:
    941
    William Brogden
    Jul 11, 2003
  2. Fran Cotton

    Servlet URL Mapping Evil!

    Fran Cotton, Jul 25, 2003, in forum: Java
    Replies:
    0
    Views:
    3,367
    Fran Cotton
    Jul 25, 2003
  3. Barney Barumba
    Replies:
    0
    Views:
    6,297
    Barney Barumba
    Nov 27, 2003
  4. circuit_breaker
    Replies:
    2
    Views:
    2,016
    Jack Jia
    Apr 4, 2004
  5. Replies:
    0
    Views:
    8,316
Loading...

Share This Page