Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing Service Unavailable Alert in JAX-RS  RSS feed

 
Prabhash Mishra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hell All,
           I am working with jaxrs.I want to show alert to user tha server is not available or service is down.Can anybody give me how i willl be able to implement this.

Thanks,
Prabhash
 
Rob Spoor
Sheriff
Posts: 21047
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three easy ways:

1) Throw a WebApplicationException with Response.Status.SERVICE_UNAVAILABLE as status

2) Let the method return Response, and use Response.status(Response.Status.SERVICE_UNAVAILABLE) as the entry point to create a builder that creates the rest of the response. Returns this response.
The main drawback however is that success responses also have to be returned as Response.

3) A combination of 1) and 2): throw a WebApplicationException with a Response you built.
 
Prabhash Mishra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
   Thanks for your suggestion.I am using ExceptionMapper to show custom exception in xml format.But with exception mapper i am throwing my custom error when id not exists or list of records is empty.But sending alert for server is not available or server is down i am not able to find what will be the condition when error will be thrown.Can you suggest me the condition that i will put in my program to throw Service unavailable exception basically want too know how to detect server is not available.

Thanks,
Prabhash
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!