• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling user requests/errors printing on ajax app

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Build a response that you can check for on the clientside

If you use JSON it is easy





Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic