Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > problem: j2ee, web.xml, about set 2 servlet mapping to the same url

Reply
Thread Tools

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

 
 
sods
Guest
Posts: n/a
 
      01-07-2006
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


 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      01-08-2006
sods <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
josh.s17@gmail.com
Guest
Posts: n/a
 
      01-08-2006
Can you paste the relevant section of the web.xml file into your post
so we know exactly what you mean.

 
Reply With Quote
 
sods
Guest
Posts: n/a
 
      01-09-2006

"Chris Smith" <(E-Mail Removed)> дʼ
news:(E-Mail Removed).. .
> sods <(E-Mail Removed)> 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


 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      01-09-2006
sods <(E-Mail Removed)> 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
 
Reply With Quote
 
sods
Guest
Posts: n/a
 
      01-09-2006

<(E-Mail Removed)> дʼ
news:(E-Mail Removed) ups.com...
> 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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: servlet annotations for URL mapping? Mike Schilling Java 3 05-02-2008 04:53 PM
how can I get the servlet access url from servlet context shaoanqing@gmail.com Java 4 04-20-2007 09:10 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Servlet URL Mapping Evil! Fran Cotton Java 0 07-25-2003 03:41 PM
problems with servlet-mapping url-pattern lbrtchx Albretch Java 2 07-11-2003 08:19 PM



Advertisments