Filter request wrapper ClassCastException - Weblogic
This is a discussion on Filter request wrapper ClassCastException - Weblogic ; Hi all:
I want to implement a filter that process the servlet request, then I was implement
a filter and a class that extend the HttpServletRequestWrapper class. The problem
is that when I class the doFilter method with my new ...
-
Filter request wrapper ClassCastException
Hi all:
I want to implement a filter that process the servlet request, then I was implement
a filter and a class that extend the HttpServletRequestWrapper class. The problem
is that when I class the doFilter method with my new class the server throw java.langClassCastException.
I don't know if I'm doing something wrong because there's a lot of references
and examples to wrap the response but not so many to wrap the request.
I simplify the code to test what's the problem and this is my wrapper class and
the relevant servlet code.
// Wrapper class
public class CompressionServletRequestWrapper extends HttpServletRequestWrapper
{
public CompressionServletRequestWrapper(HttpServletReques t request) throws
IOException{
super(request);
}
}
// Filter servlet
CompressionServletRequestWrapper wrappedRequest =null;
boolean entradaComprimida=false;
wrappedRequest=new CompressionServletRequestWrapper( httpRequest);
chain.doFilter(wrappedRequest, response);
Best Regards
Miguel Angel
-
Re: Filter request wrapper ClassCastException
I bet your consumer is a JSP, eh? I hear the wrappers work going to a
Servlet but not to a JSP (that gets turned into a Servlet when compiled...).
I tried a sample I found for the Response wrapper from a compression filter
This looks like it will do what you want to do....
http://www.orionserver.com/tutorials...ZIPFilter.html
I want to make a filter that allows me to set/modify a Request Header (not a
Request Attribute nor a Response Header) and ran into the same issue, lots
of people saying "Use the HttpServletRequestWrapper" and "look at the
specs"; but no one with a code sample that actually WORKS!!!
Doris Chen from Sun just sent me this link to one of her code camps:
http://developer.java.sun.com/develo...n1/dchen1.html
and suggests Mary Hall's book "More Servlets and JavaServer Pages" (and the
filters section in Servlets2.3 spec too - figures...)
I haven't checked out the code camp nor the book yet. Post back if you
figure this out.
Thanks,
--
Michael J. Geiser
"Miguel Ángel" wrote in message
news:3f26674a$1@newsgroups.bea.com...
Hi all:
I want to implement a filter that process the servlet request, then I was
implement
a filter and a class that extend the HttpServletRequestWrapper class. The
problem
is that when I class the doFilter method with my new class the server throw
java.langClassCastException.
I don't know if I'm doing something wrong because there's a lot of
references
and examples to wrap the response but not so many to wrap the request.
I simplify the code to test what's the problem and this is my wrapper class
and
the relevant servlet code.
// Wrapper class
public class CompressionServletRequestWrapper extends
HttpServletRequestWrapper
{
public CompressionServletRequestWrapper(HttpServletReques t request)
throws
IOException{
super(request);
}
}
// Filter servlet
CompressionServletRequestWrapper wrappedRequest =null;
boolean entradaComprimida=false;
wrappedRequest=new CompressionServletRequestWrapper( httpRequest);
chain.doFilter(wrappedRequest, response);
Best Regards
Miguel Angel
-
Re: Filter request wrapper ClassCastException
That was a problem in 6.1 ... are you on 6.1?
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Miguel Ángel" wrote in message
news:3f26674a$1@newsgroups.bea.com...
>
> Hi all:
>
> I want to implement a filter that process the servlet request, then I was
implement
> a filter and a class that extend the HttpServletRequestWrapper class. The
problem
> is that when I class the doFilter method with my new class the server
throw java.langClassCastException.
>
> I don't know if I'm doing something wrong because there's a lot of
references
> and examples to wrap the response but not so many to wrap the request.
>
> I simplify the code to test what's the problem and this is my wrapper
class and
> the relevant servlet code.
>
> // Wrapper class
> public class CompressionServletRequestWrapper extends
HttpServletRequestWrapper
> {
>
> public CompressionServletRequestWrapper(HttpServletReques t request)
throws
> IOException{
> super(request);
> }
>
> }
>
> // Filter servlet
> CompressionServletRequestWrapper wrappedRequest =null;
> boolean entradaComprimida=false;
> wrappedRequest=new CompressionServletRequestWrapper( httpRequest);
> chain.doFilter(wrappedRequest, response);
>
>
> Best Regards
>
> Miguel Angel
>
>
-
Re: Filter request wrapper ClassCastException
No, I'm on 7.0 SP3. What was the problem in that version and what is the solution?
Perhaps the problem still remain.
Thank you
"Cameron Purdy" wrote:
>That was a problem in 6.1 ... are you on 6.1?
>
>Peace,
>
>Cameron Purdy
>Tangosol, Inc.
>http://www.tangosol.com/coherence.jsp
>Tangosol Coherence: Clustered Replicated Cache for Weblogic
>
>
>"Miguel Ángel" wrote in message
>news:3f26674a$1@newsgroups.bea.com...
>>
>> Hi all:
>>
>> I want to implement a filter that process the servlet request, then
>I was
>implement
>> a filter and a class that extend the HttpServletRequestWrapper class.
>The
>problem
>> is that when I class the doFilter method with my new class the server
>throw java.langClassCastException.
>>
>> I don't know if I'm doing something wrong because there's a lot of
>references
>> and examples to wrap the response but not so many to wrap the request.
>>
>> I simplify the code to test what's the problem and this is my wrapper
>class and
>> the relevant servlet code.
>>
>> // Wrapper class
>> public class CompressionServletRequestWrapper extends
>HttpServletRequestWrapper
>> {
>>
>> public CompressionServletRequestWrapper(HttpServletReques t request)
>throws
>> IOException{
>> super(request);
>> }
>>
>> }
>>
>> // Filter servlet
>> CompressionServletRequestWrapper wrappedRequest =null;
>> boolean entradaComprimida=false;
>> wrappedRequest=new CompressionServletRequestWrapper( httpRequest);
>> chain.doFilter(wrappedRequest, response);
>>
>>
>> Best Regards
>>
>> Miguel Angel
>>
>>
>
>
-
Re: Filter request wrapper ClassCastException
>>> I want to implement a filter that process the servlet request, then
>>> I was implement a filter and a class that extend the
>>> HttpServletRequestWrapper class. The problem is that when I class
>>> the doFilter method with my new class the server
>>> throw java.langClassCastException.
>> That was a problem in 6.1 ... are you on 6.1?
> No, I'm on 7.0 SP3. What was the problem in that version and what is
> the solution? Perhaps the problem still remain.
The problem was that WL code casted the request object to a specific WL
implementation of request, which was a bug.
Can you post the full stack trace of the exception? That should provide a
clue or two.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Miguel Angel" wrote in message
news:3f27d507$1@newsgroups.bea.com...
>