Reputation: 75
I want to display error message but I not clear get the error message. I just want display just the message, but in my case I show the message and the tag html, I already change the content type to text/plain. my code:
response.setContentType("text/plain");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, "user atau pass salah men!");
in error message in ajax, I alert(error.responseText); show:
user atau pass salah men!
how to get the message without the html tag? thanks
Upvotes: 0
Views: 1086
Reputation: 6324
When you call response.sendError
the container is generating an html page with your message. What you need to do instead is get an OutputStream from the response with response.getOutputStream()
and write your message to it.
You can write your message to the stream with:
response.getOutputStream().write("user atau pass salah men!".getBytes());
Upvotes: 1