|
|
Mozy Online Backup: 2GB Free. Automatic. Secure.
Subject: Re: Request Wrapper problem - msg#00256
List: java.jetty.support
Geoffrey,
You cannot assume that your request/response wrappers will be passed
through unwrapped.
But you can assume that your wrapper is somewhere in the wrapped
stack of requests/respones. Thus if you REALLY need to get at
your original wrappers, you can ask a wrapper for it's wrapped
request/response until you find your request/response.
But you have to suspect that your design is a bit wrong if
you need to do this? Maybe you want to consider passing
stuff as request attributes rather than adding not standard
methods.
picrong wrote:
> Hello,
>
> I'm new to jetty.
>
> I try to test a web app developped in my company on it and that is
> running on Tomcat and weblogic without any problem.
>
> The deployment was quite easy, but...
>
> Now I have the following problem.
>
> In my app, the HttpServletRequest in wrapper in our own wrapper.
> The code in jsp pages then cast the request to the wrapper.
>
> In Jetty, it seems that the dispatcher wrap the request to, so when I
> try to cast it ...
>
> java.lang.ClassCastException:
> org.mortbay.jetty.servlet.Dispatcher$DispatcherRequest
>
>
> Is anybody meet this problem ?
> Is anybody has an idea to make it work without changing all ?
>
> Geoffrey
>
>
>
> For the latest information about Jetty, please see http://jetty.mortbay.org
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
--
Greg Wilkins<gregw@xxxxxxxxxxx> GB Phone: +44-(0)7092063462
Mort Bay Consulting Australia and UK. Mbl Phone: +61-(0)4 17786631
http://www.mortbay.com AU Phone: +61-(0)2 98107029
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: Jetty/HTTP Status codes/SOAP dont mix?
Chris,
I assure you that under normal operation setStatus and sendError both
work fine??? I just wrote the following test servlet:
public class SetStatus extends HttpServlet
{
/* ------------------------------------------------------------ */
public void doPost(HttpServletRequest sreq, HttpServletResponse sres)
throws ServletException, IOException
{
doGet(sreq,sres);
}
/* ------------------------------------------------------------ */
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setStatus(500);
PrintWriter out=res.getWriter();
out.write("<H1>Test 500 status</H1>");
out.flush();
}
}
And tested it using telnet as follows:
[502] telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /jetty/servlet/SetStatus HTTP/1.0
HTTP/1.1 500 Internal Server Error
Date: Wed, 31 Jul 2002 13:09:58 GMT
Server: Jetty/4.0.3 (Linux 2.4.18 i386)
Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.4.0_01)
<H1>Test 500 status</H1>Connection closed by foreign host.
gregw@wafer: ~
[503] telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST /jetty/servlet/SetStatus HTTP/1.0
HTTP/1.1 500 Internal Server Error
Date: Wed, 31 Jul 2002 13:10:50 GMT
Server: Jetty/4.0.3 (Linux 2.4.18 i386)
Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.4.0_01)
<H1>Test 500 status</H1>Connection closed by foreign host.
Can you tell me a bit more about your setup????? Are any other servlets
or filters involved?
chris_wassman wrote:
> First off, I am using:
> Server: Jetty/4.0.4 (Linux 2.4.18-3 i386)
> Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.3.1_03)
>
> My problem is that I do not seem to be able to change the HTTP status
> code line at all from a servlet contained within Jetty. I have tried
> two distinct approaches, both from within the my Servlet code in the
> service(HttpServletReqeust, HttpServletResponse) method of the servlet
> contained within Jetty.
>
> I have tried the following: (res is the HttpServletResponse)
> res.setStatus(500);
> and
> res.sendError(500);
>
> I would expect these to generate an HTTP Response with the first line
> like this:
> HTTP/1.1 500 Some_error_message
>
> Instead I alwasy get:
> HTTP/1.1 200 OK
>
> This is an issue for me because I am trying to implement a web service
> in SOAP. The SOAP specs dictate that on an exception I must set the
> status code to 500 as well as return a SOAP fault msg. Currently I
> cannot meet the SOAP specs because Jetty seems to hard code this '200
> OK' message.
>
> I have attempted to locate the responsible code inside of Jetty, but
> am not familar with the Jetty codebase currently... but I have been
> unable to find the place in which this first line is set at all. :(
>
> Some more information on this issue:
> The following appears in the debug logs (which is puzzling to me):
> 20:54:58.246 DEBUG
> [SocketListener-0/0]org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:997)06>
> RESPONSE:
> HTTP/1.1 500 Internal Server Error
> Jetty-Request: POST /Test/xyz HTTP/1.1
> Date: Wed, 31 Jul 2002 03:54:57 GMT
> Server: Jetty/4.0.4 (Linux 2.4.18-3 i386)
> Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.3.1_03)
> Connection: close
> Content-Type: text/xml
>
> +++Which is what I would expect to be returned to the client. (Along
> with the message body)
>
> +++The NCSA log entry looks like this:
> 10.0.0.100 - - [30/Jul/2002:21:46:10 -0800] "POST /Test/xyz HTTP/1.1"
> 500 1782 "-" "-"
>
> +++But, Here's whats returned to the client:
> HTTP/1.1 200 OK
> Jetty-Request: POST /Test/xyz HTTP/1.1
> Date: Wed, 31 Jul 2002 03:54:57 GMT
> Server: Jetty/4.0.4 (Linux 2.4.18-3 i386)
> Servlet-Engine: Jetty/1.1 (Servlet 2.3; JSP 1.2; java 1.3.1_03)
> Connection: close
> Content-Type: text/xml
>
> +++I know this is not a client issue, as I can telnet into the Jetty
> machine and hand make a request which generates the same HTTP header
> back to me.
>
> +++ There is content in the ServletOutputStream.
>
> +++ setStatus(500) does everything I need it to, except that the first
> line does not have the appropriate status code.
>
> +++ sendError(500) does 2 things which I do not wish. 1: does not
> have the appropriate status code. 2: appends an HTML message to the
> data that I've already dumped into the ServletOutputStream.
>
> Any advice appreciated... If someone even knows where this string gets
> put into the OutputStream by Jetty, that could be helpful as well. I
> can work on the solution myself, if given direction and would glady
> return the code to the Jetty group.
>
> Cheers,
> Chris.
>
>
>
> For the latest information about Jetty, please see http://jetty.mortbay.org
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
--
Greg Wilkins<gregw@xxxxxxxxxxx> GB Phone: +44-(0)7092063462
Mort Bay Consulting Australia and UK. Mbl Phone: +61-(0)4 17786631
http://www.mortbay.com AU Phone: +61-(0)2 98107029
Previous Message by Thread:
click to view message preview
Request Wrapper problem
Hello,
I'm new to jetty.
I try to test a web app developped in my company on it and that is
running on Tomcat and weblogic without any problem.
The deployment was quite easy, but...
Now I have the following problem.
In my app, the HttpServletRequest in wrapper in our own wrapper.
The code in jsp pages then cast the request to the wrapper.
In Jetty, it seems that the dispatcher wrap the request to, so when I
try to cast it ...
java.lang.ClassCastException:
org.mortbay.jetty.servlet.Dispatcher$DispatcherRequest
Is anybody meet this problem ?
Is anybody has an idea to make it work without changing all ?
Geoffrey
|
|