[opencms-dev] Re: Declare http status (404/301/...) in JSP
Martin van den Bemt
mvdb at ibl-software.nl
Tue Nov 22 12:22:39 CET 2005
Thorsten Duhn wrote:
>> It seems to me it's got the do with this entry in the web.xml :
>> If the handle404 cannot find a resource it probably is just not
>> sending a 404 to the browser, just a page saying that the resource
>> is not found (afaik)..
>> So in my view, the 404handler in opencms needs fixing.
> are you sure this is the same problem? I would think, this is
> for the handling of "real" 404s, means that a requested file
> is not available in VFS. Isn't that fixed already?
I am not on the latest and greatest I must admit :) And now you mention
it I am not sure it is the same problem :)
> What I'm talking about is to explicitly set a http response in
> a jsp page (f.e. based on request parameters, an id of my own
> database content, where no content is returned for this id).
> I can set a 404 in response object, but it is never sent to
> browser, it obviously is replaced by OpenCms with a 200 status
Couple of things (maybe obvious, but you never know) :
- after a response.sendError(404) you should directly stop processing
the jsp, so add a return after the sendError
- It could be that the response object is wrapped by opencms (if I am
not mistaken it is). Try to get the original response and invoke a
sendError on that object directly (if opencms actually override sendError)
Hope this helps :)
More information about the opencms-dev