• Post Reply Bookmark Topic Watch Topic
  • New Topic

Elements from HttpServletResponse  RSS feed

 
Vittorio Dell'Oste
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I don't know if this is the right section from my post...
However, I have a question: can I take values from HttpServeletResponse?
In debug, I can see that HttpServeletResponse is a ResponseFacade in runtime, and it contains an object "request". This "request" contains a "CoyoteRequest" object, and this one contains a field called "MethodMB".
But how can I retrieve this "MethodMB" value from HttpServletResponse in my code?

Thank you very much.

Ps Excuse me for my bad English.
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vittorio,

The object you look at / inspect in debug mode is an implementation of HttpServeletResponse. This is specific to a server and varies across different servers. HttpServeletResponse defines state and behaviour that all other implementing servers have to abide by. So, you can access the state and behaviour of the Response using the fields / methods defined in this interface.

If the server is written in java, you'll have to know the Class type of the response and typecast it to access 'MethodMB'. But I don't think this is ever needed or a recommended approach. Why do you need to access such values ?
 
Vittorio Dell'Oste
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi T Mishra
thank you for your fast reply.
I need to access to that value because it's the only way to retrieve the method's name, I can't do it in other ways because there are almost six classes between start (where the method is set) and end (the class with HttpServletResponse).

However, the ClassType of response is ResponseFacade.
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's revisit your use case. Is this what you're trying ?
There is some class MyClass with getters / setters.

The value is passed into the request.
Its set using MyClass.setValue();
And, now you're trying to access MyClass.getValue() from Responsefacade.

 
Vittorio Dell'Oste
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi T Mishra

the attachment show my situation during execution
Problem.jpg
[Thumbnail for Problem.jpg]
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the value is present in the request, you can process it on the server side from the request directly. You do not need a response to access that value.
this brings back to the question - why do you need to acces the value from a response? You can use request to process data and set the values in the response needed by the view.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vittorio Dell'Oste wrote: . . . the attachment show my situation during execution
It is also difficult to read; please don’t post screenshots.
 
Vittorio Dell'Oste
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T Mishra wrote:If the value is present in the request, you can process it on the server side from the request directly. You do not need a response to access that value.
this brings back to the question - why do you need to acces the value from a response? You can use request to process data and set the values in the response needed by the view.

Thank you for help, but maybe we will use a different way... I'm waiting for instructions
 
Vittorio Dell'Oste
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Vittorio Dell'Oste wrote: . . . the attachment show my situation during execution
It is also difficult to read; please don’t post screenshots.

I'm sorry, but it was very hard to copy all the three, so I used the screenshot.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies accepted, but it is still difficult to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!