This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Response Object

 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am calling a servlet (by hitting an URL from my application. The servlet will be returning the response object and the application which calls it is expecting an xml object so while sending the response i am setting the respose object as ...

But in few cases (some other application) which is also calling the same URL, expects the object returned in some cutom object. How can i set the response object for those cases.

For Example : application is expecting the response object in SampleClass object. [SampleClass is a class written by myself]......
In that case how can i set the response object...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Renu,
What file type is it. A .class file. That would be a binary file.
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is there in that class that can be executed? You can't simply try to forward to a java object.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would look into using Jersey - the open source REST style engine.

It is easy to configure Jersey classes to look at the HTTP request headers for the expected content type and return it.

This of course requires that you have control over the way your applications create requests and can set the appropriate header.

Servlets dont "return response object" they return a response stream - the headers in this stream must conform to HTTP standards but the body can be just about anything - XML, serialized Java object, image, whatever.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic