File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes can I do this in servlet-mapping? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "can I do this in servlet-mapping?" Watch "can I do this in servlet-mapping?" New topic
Author

can I do this in servlet-mapping?

Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Hello

Somebody know if I can do this in the DD:

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlte-class>foo.MyServlet</servlte-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>MyServlet.do</url-pattern>
<url-pattern>MyServletAlias1.do</url-pattern>
<url-pattern>/Alias/*</url-pattern>
</servlet-mapping>
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

No, that will violate the dtd's definition for web.xml. See this:
<!ELEMENT servlet-mapping (servlet-name, url-pattern)>

For each servlet-mapping you must have exactly one servlet-name and one url-pattern.

However, you could accomplish what you wanted by using multiple servlet-mapping tags that all contain the same value for servlet-name but with different url-pattern values.


A good workman is known by his tools.
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Thanks so that means I can do this

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlte-class>foo.MyServlet</servlte-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>MyServlet.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>MyServletAlias1.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/Alias/*</url-pattern>
</servlet-mapping>
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
Yes.

But what you did first will be possible in J2EE 1.5 (servlet spec 2.5).

But don't think this way for SCWCD 1.4


SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources: http://esnault.frederic.free.fr/certification
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
Yeah I think J2ee 1.5 got it right. the first way seems a more optimum way to do it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can I do this in servlet-mapping?