my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Handling user requests/errors printing on ajax app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Handling user requests/errors printing on ajax app" Watch "Handling user requests/errors printing on ajax app" New topic
Author

Handling user requests/errors printing on ajax app

shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Hi Guys

I am working on an AJAX app and am having problems with printing errors. Now, if the user makes a request the servlet processes this request and outputs one of two possible results, (1) The content the user requested or (2) an error message. My question is how can I print out the error messages ? I have been told I can create a custom header attribute and use the javascript to look out for it. Is this a good way of handling this issue ? Or are there better methods ?
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
You said printing errors , what errors is it related to business functionality (like no data found) or servlet processing errors like status codes from 400-500??


If you want something you never had do something which you had never done
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Both - I know how to handle the status errors, but I dont know how to handle the business functionality ones.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Hey sorry for the late reply.

Coming to the business ones , if for example if there is no data found

while(rs.next())
{
}
else
{
// construct a xml file for example :

<message>
<text>No Data Found</text>
<message>
}

show this message on to front end .

and coming to the server side errors , why dont you check the status of XMLHttpRequest has properties depending on that you can handle know
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Build a response that you can check for on the clientside

If you use JSON it is easy





Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling user requests/errors printing on ajax app
 
Similar Threads
Bear's FrontMan, how to do general error messages
Using Exceptions and ActionErrors together
jQuery Ajax Request
java.lang.IllegalStateException: getOutputStream() error
jQuery ajax request and 302 status code