tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Jenkins <rak...@jenkinssoftware.com>
Subject HttpServletResponse return plain text
Date Thu, 28 Mar 2013 04:33:44 GMT
I know this isn't the right mailing list but there's a lot
of knowledgeable people here so I'd give it a shot.

When I was hosting on Google App Engine the java servlet
HttpServletResponse.sendError would return the 2nd parameter text in plain
text.

Now that I'm hosting on Tomcat it's putting the text inside an <HTML> body.
I'd like to to return the text in plain text instead.

This is my code:
String resultStr = "Request " +  req.getRequestURI() + ": __developerId " +
__developerId + " in use.";
resp.getWriter().println(resultStr);
resp.sendError(HttpServletResponse.SC_CONFLICT, resultStr);

I tried this, but it still returned the text inside an HTML body.

resp.setContentType("text/plain");
String resultStr = "Request " +  req.getRequestURI() + ": __developerId " +
__developerId + " in use.";
resp.getWriter().println(resultStr);
resp.sendError(HttpServletResponse.SC_CONFLICT);

Anyone know how to do this?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message