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");

            return;
        }

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 10.16.12.59:8988 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" !!!

MrHaightAsked:
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.

objectsCommented:
your browser is just not displaying it I'd say.
0
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");

            return;
        }


SC_PARTIAL_CONTENT = 206
SC_BAD_REQUEST = 400

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

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
Java

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.