| 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: 347
|
|
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.
|
| Filename |
eclipse.PNG |
Download
|
| Description |
|
| Filesize |
89 Kbytes
|
| Downloaded: |
15 time(s) |
|
 |
Gamini Sirisena
Ranch Hand
Joined: Aug 05, 2008
Posts: 347
|
|
|
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: 347
|
|
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
Rancher
Joined: Apr 07, 2010
Posts: 742
|
|
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
|
 |
 |
|
|
subject: some confusion regarding filter-mapping
|
|
|