Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Servlet Response Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Response Object" Watch "Servlet Response Object" New topic
Author

Servlet Response Object

renu richard
Ranch Hand

Joined: Oct 06, 2008
Posts: 116
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...


Cheers,
Richard
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Renu,
What file type is it. A .class file. That would be a binary file.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Response Object