?
Solved

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
4
Medium Priority
?
182 Views
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");

            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" !!!

0
Comment
Question by:MrHaight
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12599158
your browser is just not displaying it I'd say.
0
 

Author Comment

by:MrHaight
ID: 12599236
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
 

Author Comment

by:MrHaight
ID: 12599239
How do I accept my own Answer!
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 12599272
I was close :)
you can just get the question deleted
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

750 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