Chuck,
I got the same error with your version. Which got me thinking. So
removed all of my webapp files and tried a again with a fresh war file
and now they both work.
Thanks!
Nathan
On Jan 29, 2009, at 8:27 PM, Caldarale, Charles R wrote:
From: Nathan Potter [mailto:n...@opendap.org]
Subject: Re: Tomcat returns HTTP status of 200 when
HttpServletResponse.sendError() called.
Sorry for not responding earlier, things have been a little hectic
this week.
I just got try it today and here is what happened:
I just tried the same thing, with no problems.
I made this class:
I don't see a package clause in your code, nor are the imports
shown. Here's the entire code I used, including the poor man's
logger, System.out:
package mypackage;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.Globals;
public class StaticContentServlet extends
org.apache.catalina.servlets.DefaultServlet {
protected String getRelativePath(HttpServletRequest request) {
// Are we being processed by a RequestDispatcher.include()?
if (request.getAttribute(Globals.INCLUDE_REQUEST_URI_ATTR) !=
null) {
String result =
(String)request.getAttribute(Globals.INCLUDE_PATH_INFO_ATTR);
if (result == null) {
result =
(String)request.getAttribute(Globals.INCLUDE_SERVLET_PATH_ATTR);
}
if (result == null || result.equals("")) result = "/";
System.out.println("StaticContentServlet returning " + result);
return result;
}
// No, extract the desired path directly from the request.
String result = request.getPathInfo();
if (result == null) {
result = request.getServletPath();
} else {
result = request.getServletPath() + result;
}
if (result == null || result.equals("")) result = "/";
System.out.println("StaticContentServlet returning " + result);
return result;
}
}
I added it to my web.xml file:
Mine is almost the same, with the addition of a listings param:
<servlet>
<servlet-name>docs</servlet-name>
<servlet-class>mypackage.StaticContentServlet</servlet-class>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
just so the /docs mapping would do something useful. (The servlet
mappings are identical to yours.)
Referencing the URLs:
http://localhost:8080/sample/docs
http://localhost:8080/sample/docs/test.txt
got me this result in stdout:
StaticContentServlet returning /docs
StaticContentServlet returning /docs/test.txt
and the expected directory listings and the text file contents in
the browser window.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
PROPRIETARY MATERIAL and is thus for use only by the intended
recipient. If you received this in error, please contact the sender
and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
= = =
Nathan Potter ndp at opendap.org
OPeNDAP, Inc. 541.752.1852
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org