jersey.api.client.WebResource - how to debug/log the request headers

江枫思渺然 提交于 2019-12-05 08:27:15
ivan.cikic

You can use LoggingFilter, as shown here

You need to add init-params and then implement ContainerRequestFilter

Put it in your web.xml Please note that com.az.jersey.server.AuthFilter is your class that has implemented mentioned above interface.

<init-param>
            <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
            <param-value>com.sun.jersey.api.container.filter.LoggingFilter;com.az.jersey.server.AuthFilter</param-value>
        </init-param>



public class AuthFilter implements ContainerRequestFilter {
    /**
     * Apply the filter : check input request, validate or not with user auth
     * 
     * @param containerRequest
     *            The request from Tomcat server
     */
    @Override
    public ContainerRequest filter(ContainerRequest containerRequest) throws WebApplicationException {
        //GET, POST, PUT, DELETE, ...
        String method = containerRequest.getMethod();
        // myresource/get/56bCA for example
        String path = containerRequest.getPath(true);         

        return containerRequest;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!