Reputation: 5329
I am working on a use case where I am displaying user's messages on a JSP. Details of the flow are:
I have tried to implement by referring to these SO questions:
However, it's not solving my purpose. I have the following questions:
MediaType
for @Produces
annotation in my resource method? Currently my resource is annotated with @Produces(MediaType.APPLICATION_JSON)
. Will this work?Any pointers appreciated. TIA.
Upvotes: 1
Views: 8606
Reputation: 1579
You can add custom data to the response Header, so yes you are able to send such message data. Add the data to the response Header.
@Produces(MediaType.APPLICATION_JSON)
will not work, unless the clients will accept JSON as a file, what they should and will not do ;)
The correct MediaType
depends on what kind of file you want to submit.
You can use the default MediaType / MIME-Type MediaType.APPLICATION_OCTET_STREAM
/ application/octet-stream
(Is there a “default”
MIME type?) but I think it's better to use the correct and exact MIME-Type for your file.
You will find working examples for sending file data with jersey in Input and Output binary streams using JERSEY? - so there is no need to answer this again :)
Hope this was helpful somehow, have a nice day.
Upvotes: 1