filter

O

odelya

Hello!
I wrote the ffollowing filter:
private FilterConfig filterConfig = null;

/**
* overwritten.
*/
public void destroy() {
filterConfig = null;

}

/**
* filters parameters: ContentType and expires.
*/
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
if (filterConfig == null)
return;
HttpServletRequest request = (HttpServletRequest) arg0;
HttpServletResponse response = (HttpServletResponse) arg1;
System.out.print(request.getContextPath());
System.out.print(request.getContentLength());

arg2.doFilter(request, response);
}

/* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig arg0) throws ServletException {
this.filterConfig = arg0;

}
and i get messege:
for ContextPath(): /servlet
for ContentLength(): -1.
How come I don't get any content?

Thank you
 
G

GArlington

Hello!
I wrote the ffollowing filter:
private FilterConfig filterConfig = null;

/**
* overwritten.
*/
public void destroy() {
filterConfig = null;

}

/**
* filters parameters: ContentType and expires.
*/
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
if (filterConfig == null)
return;
HttpServletRequest request = (HttpServletRequest) arg0;
HttpServletResponse response = (HttpServletResponse) arg1;
System.out.print(request.getContextPath());
System.out.print(request.getContentLength());

arg2.doFilter(request, response);
}

/* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig arg0) throws ServletException {
this.filterConfig = arg0;

}
and i get messege:
for ContextPath(): /servlet
for ContentLength(): -1.
How come I don't get any content?

Thank you

ContentLength() = -1 is not empty, it is unknown.
See http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#getContentLength()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top