Why won't this send an HTML formatted error message with the message included? res.sendError(res.SC_BAD_REQUEST, "Street is null");

Here is my code:

 String strStreet = req.getParameter("strStreet");

        if (strStreet == null) {
            res.sendError(res.SC_BAD_REQUEST, "Street is null");


Here is what is returned to the client upon strStreet equalling null:

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.


Please try the following:

If you typed the page address in the Address bar, make sure that it is spelled correctly.

Open the home page, and then look for links to the information you want.
Click the  Back button to try another link.
Click  Search to look for information on the Internet.

HTTP 400 - Bad Request
Internet Explorer  

Where is the message "Street is null" !!!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

your browser is just not displaying it I'd say.
MrHaightAuthor Commented:
I figured it out.  Apparently you can't send back a message unless the error code is < 400.  So in my case, since the error code was 400, it didn't send back the message.  I tried this code and it worked:

        if (strStreet == null) {
            res.sendError(res.SC_PARTIAL_CONTENT, "Street is null");



Thanks anyway!
MrHaightAuthor Commented:
How do I accept my own Answer!
I was close :)
you can just get the question deleted

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.