aspose file tools*
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
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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: 12681
    
    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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Response Object
 
Similar Threads
Solution for repeating function in all servlets.
How Inheritance Affects Serialization
not able to get ContextPath(); getting null pointer exception
How to access the JSON reponse from a java client
How to set active sheet in Excel sheet?