Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
sods - 07 Jan 2006 11:48 GMT
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
Chris Smith - 08 Jan 2006 03:02 GMT
> 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.

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

sods - 09 Jan 2006 05:23 GMT
> > 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.

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
Chris Smith - 09 Jan 2006 06:57 GMT
>     <!-- Standard Action Servlet Mapping -->
>     <servlet-mapping>
[quoted text clipped - 5 lines]
>         <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.

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

josh.s17@gmail.com - 08 Jan 2006 08:40 GMT
Can you paste the relevant section of the web.xml file into your post
so we know exactly what you mean.
sods - 09 Jan 2006 09:31 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.