aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes some confusion regarding filter-mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "some confusion regarding filter-mapping" Watch "some confusion regarding filter-mapping" New topic
Author

some confusion regarding filter-mapping

Faiz A Chachiya
Greenhorn

Joined: Jun 05, 2007
Posts: 12
I have some query regarding the filter-mapping specified in DD which is as below

<filter-mapping>
<filter-name>FilterA</filter-name>
<servlet-name>RedServlet</servlet-name>
</filter-mapping>

As per my knowledge url-pattern is mandatory and either filter-name or servlet-name should be there. I feel that the declaration is not valid

Can anyone clarify if filter-mapping declaration is valid or invalid...
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 349
apart from reading the xsd for your particular webapp version, if you have eclipse,
you could create a dynamic web application and right click on the created web.xml
and click open with->xml editor and click on the design view tab.

Now by right clicking on the web-app you can add your child elements

For web app version 2.4 these seem to be the mandatory elements...

<filter>
<filter-name>token</filter-name>
<filter-class>token</filter-class>
</filter>
<filter-mapping>
<filter-name>token</filter-name>
<url-pattern>url-pattern</url-pattern>
</filter-mapping>

There is no servlet-name child for filter-mapping
Faiz A Chachiya
Greenhorn

Joined: Jun 05, 2007
Posts: 12
Well I tried creating the filter-mapping using the Eclipse design view. it shows the servlet-name as one of the optional attributes. Please check the attachment.

I have got answer to my question... the filter-name is mandatory and (either url-pattern or servlet-name) is required.


[Thumbnail for eclipse.PNG]

Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 349
You are right.. I guess you used web app version 3.. that does have a servlet-name child element for filter-mapping
Faiz A Chachiya
Greenhorn

Joined: Jun 05, 2007
Posts: 12
The version used is 2.4 and not 3.0, have a look at the attachment it clearly shows the version
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 349
You are right again.. I was checking the add child item. When I right clicked the url-pattern element and pointed to the Replace With, servlet-name was there..

I think both the right click menus and the content column can be used to figure out what's available and not.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

Hi Guys,

Although you got your answer I just wanted to show you a place where you can easily get the answer as well. There are nice Deployment Descriptor Diagrams included in the Servlet spec. Download for instance the Servlet 2.4 spec and got to SRV.13.4 Deployment Descriptor Diagram on page 135

You will this diagram: FilterMapping diagram

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: some confusion regarding filter-mapping