Tagged: java

Jersey Logo 3

Serving Files using Jersey Web Service (JAX-RS)

There are a lot of tutorials out there explaining how to send binary data (i.e. application/octet-stream) as response for Jersey web services (Java JAX-RS). Two possible solutions are based on either returning a Response or StreamingObject containing the appropriate binary data stream. Below you find a simple example for both...

Source Code Icon 2

Selecting nth sibling using XPath

XPath (XML Path Language) can be used to parse highly complex XML structures without the need to iterate over each node independently. A likely use case is to select the nth sibling or nth element from a list. Luckily, this can be easily achieved by using position(). To demonstrate the...

Bugfix für urbanairship-java SDK JsonParseExceptionBugfix for urbanairship-java SDK JsonParseException 0

Bugfix für urbanairship-java SDK JsonParseExceptionBugfix for urbanairship-java SDK JsonParseException

There (still) exists a bug in urbanairship-java SDK related to parsing valid ISO8601 dates. The original bug report can be found here: GSon date parsing error. The Cause ISO8601 states that for date-time strings the separator “T” can be left out. Unfortunately the urbanairship-java SDK expects only fully qualified ISO8601...

Jersey Logo 0

Custom Response Types in Jersey SecurityContext

Sometimes you might need to return custom response types in your SecurityContext implementation when using Jersey RESTFul web services. Basically, there are two options available to do so: Use javax.ws.rs.core.Response and throw a WebApplicationException or write your own ExceptionMapper Throw WebApplicationException Custom ExceptionMapper The other (even nicer option) is to...

Jersey Logo 2

Setting Character Set for Jersey Web Services

When developing RESTful Web services using Jersey you will at some point be forced to define/change the character set and content type of your response. Setting the content type is simply done by using the Produces tag, like so: At this point it comes in handy to know that Jersey...