• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why ServletResponse doesn't have any attribute methods?

 
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of adding attribute to the request object that's being passed to any 'view' from a servlet for e.g., it is better to add it to the response object - that sounds intuitive. It's like - servlet does something with the request (input) and passes on its results (output) through response object to the next item in action.

Looks weird? Please share your thoughts.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A response is generated once it's been determined how a request should be handled. So from that I find it more natural to attach attributes to requests, because the request will exist even when the response does not yet.

On a more practical level, I think it would be confusing to have attributes for both. By choosing one, it's clear where to look for attributes.
 
Faisal Ahmad
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:'Have' is correct English. Why do you want to change it to 'has'



I have some confusion regarding when to use 'doesn't have' and 'doesn't has'. I searched for some guidance on the web but I'm not fully convinced with the info that I found so far.
 
Faisal Ahmad
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:A response is generated once it's been determined how a request should be handled.



You mean - ServletResponse reference that is passed to a servlet doesn't refer to an existing object?


Ulf Dittmer wrote:So from that I find it more natural to attach attributes to requests, because the request will exist even when the response does not yet.

On a more practical level, I think it would be confusing to have attributes for both. By choosing one, it's clear where to look for attributes.



Consider the below flow:

Container passes client's request as an input to Servlet -> Servlet processes the input and adds its output/response to the ServletResponse object and then passes on these objects to next in action (view for e.g.) -> View checks the ServletResponse and performs some action based on the what it found.

It's Servlet's response. So, isn't it more intuitive/logical to find it in a 'ServletResponse' object?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ServletResponse reference that is passed to a servlet doesn't refer to an existing object?


No, the object is real. I meant the actual HTTP response.

Container passes client's request as an input to Servlet -> Servlet processes the input and adds its output/response to the ServletResponse object and then passes on these objects to next in action (view for e.g.) -> View checks the ServletResponse and performs some action based on the what it found.

It's Servlet's response. So, isn't it more intuitive/logical to find it in a 'ServletResponse' object?


I'd consider that a rather uncommon design. I wouldn't start assembling the response until I knew what exactly I'm about to assemble. That doesn't mean that response post-processing isn't useful at all (HTTP compression comes to mind), but if it needs additional information, then that information is determined by the request, not the response. Of course, what's intuitive to one person needn't be intuitive to some other person. But I do think it's better to attach attributes only to one of the objects, not to both, as I mentioned before.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Faisal Ahmad wrote:

Maneesh Godbole wrote:'Have' is correct English. Why do you want to change it to 'has'



I have some confusion regarding when to use 'doesn't have' and 'doesn't has'. I searched for some guidance on the web but I'm not fully convinced with the info that I found so far.



"Doesn't has" is always incorrect. It's a contraction of "... does not have", and in that case "does" is the verb that you're conjugating, and "have" is an infinitive. So "I do not have", "he does not have", "they do not have" etc.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic