Why Filter does't work?

I want to write a plugin with servlet filter to process upload data.
The filter class is below and only for testing:
@Component
public class UploadFilter implements Filter {
FilterConfig initFilterConfig = null;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
initFilterConfig = filterConfig;
}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
    HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
    httpResponse.sendError(401, "Not Auth!");
    return;
}

@Override
public void destroy() {
    initFilterConfig = null;
}

}

the config file is :slight_smile:

${project.description} ${project.version} images/pluginIcon.png images/pluginLogo.png
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="encrypt"/>

<!-- add our web resources -->
<servlet-filter name="Uploadfile  decrypt file Servlet Filter" key="uploadfile-decrypt" class="com.hisense.filter.UploadFilter" system="false" location="before-dispatch" weight="100">
    <description>decrypt</description>
    <url-pattern>/hello</url-pattern>
    <init-param>
        <param-name>defaultName</param-name>
        <param-value>Australia</param-value>
    </init-param>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</servlet-filter>

when I request localhost:8090/hello ,the response is not 401 error. this means the filter does’t work.
Is my setting error? anyone can help me.

Hi,

Not sure which product you are using but give it a try with localhost:8090/confluence/hello for Confluence or localhost:8090/jira/hello for Jira.

Regards

The root cause is that two javax.servlet.filter version conflict.Thanks