File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Better way to send a http response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Better way to send a http response" Watch "Better way to send a http response" New topic

Better way to send a http response

Jill scott

Joined: Nov 30, 2009
Posts: 1

I have a servlet that responds to a request with value for 3 fields, say a="1" b="2" and c="3"

Which is the better way to send these as response? setting these as parameters in ServletRequest object or putting these values in a Serializable POJO and send it to client?

Please respond
AjayKumar Panigrahi

Joined: Nov 21, 2009
Posts: 21
Hi jill
That depends on your application.what are you interested to do with those values?
As far i am concerned, its better to set these parameters in ServletRequest if you just need to respond.And if you need to store it in the database better to go with plain old java objects.Its good architecture DAO data access object

Ajay Kumar, SCJP5
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

What is the client? How does it expect the information? What is it going to do with it?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Better way to send a http response
It's not a secret anymore!