Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling user requests/errors printing on ajax app

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both - I know how to handle the status errors, but I dont know how to handle the business functionality ones.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Build a response that you can check for on the clientside

If you use JSON it is easy





Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic