Reputation: 9512
I'm trying to send back an HTTP coded with some HTML. I get "the method sendStatus(int, String) is undefined for the type HttpServletResponse" error. I also tried with only the code. If I use sendError() instead, then the HTML is not sent.
<%@page contentType="text/html; charset=utf-8" %>
<%@ page isErrorPage = "true"%>
<%response.sendStatus(500, "TEST 500 ERROR WITH HTML PAGE");%>
<html>
<body>
<h1>
Test HTTP Error: 500 ERROR with HTML page
</h1>
</body>
</html>
I'm getting:
ERROR_500_subjectdoc_htmlheader_error_realhtmlerrorpage.jsp:3:12: The method sendStatus(int, String) is undefined for the type HttpServletResponse
<%response.sendStatus(500, "TEST 500 ERROR WITH HTML PAGE");%>
Upvotes: 0
Views: 2371
Reputation: 1502716
Did you mean the deprecated setStatus
method instead? Or perhaps sendError
? The error message is pretty clear - there's no such method as sendStatus(int, String)
, and the documentation confirms this.
Do you really need to set a message with the status though? Any reason not to just use setStatus(500)
?
Upvotes: 2
Reputation: 4704
You have the setStatus(int, String)
or the sendError(int, String)
methods on HttpServletResponse
Good luck
Upvotes: 0