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

Posted on 2004-11-16
Last Modified: 2010-05-18
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" !!!

Question by:MrHaight
    LVL 92

    Expert Comment

    your browser is just not displaying it I'd say.

    Author Comment

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


    SC_BAD_REQUEST = 400

    Thanks anyway!

    Author Comment

    How do I accept my own Answer!
    LVL 92

    Accepted Solution

    I was close :)
    you can just get the question deleted

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    This video teaches viewers about errors in exception handling.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now