• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to get a response (HTTPServletResponse) to a string?

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a servlet. The request coming into the servlet has to be saved in a Database.
And the it has to be redirected to a URL.
After it's redirected, I want to get the response to a string which I should ultimately copy to a database.

I am able to :
get the request, save it in the DB, redirect to the URL.

I am not able to :
get the response to a string so that I can save it in the DB.

Any idea how I will do this?

Thanks for your suggestions.


 
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I asked this in the other post. Please explicitly define what you are trying to save to the DB (and why!)
 
patt rich
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for taking interest in the topic.

My aim is to save the request and response in the database table for future reference actually. I store them as varachar in the SQLServer database.
 
Sheriff
Posts: 26961
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still not making sense. My best guess at what you mean is that you want to capture the data which is sent to the response's output stream in the form of a String. Is that anywhere near right?
 
Bear Bibeault
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"save the request" is completely ambiguous. I have no idea what you are saving.
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

patt rich wrote: I am not able to :
get the response to a string so that I can save it in the DB.


The information provided is only leaving us wild guesses. How and what are you trying to get from the response? What all you want from the response? Please set some pointers.

Regards
 
patt rich
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I mentioned about saving the request and response, this is what I meant..

Before the HTTPServletRequest is sent out, I have got it in an inputstream and read it to a Stringbuffer. Then I made a string out of it and saved that string in the Database.
Now I decided to send the request object to a URL which is actually hitting a webservice and certain things are happening there.
So, the same way I got the request to a string, I am also expecting that I can get the response object and read that data out to a string and save that in the database.

Does that make any sense? Or am I confusing you guys more?
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so it IS actually what you were saying earlier. I was just not able to imagine the "why and how" of the problem and the "what" was something weird.
Anyways, HTTPServletRequest is a request OBJECT. Why you want it to be treated as a string? Or extracted the particular values and appended them to the sb?

 
patt rich
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the reason why we extracted the content out of it to string is because that was found as the easiest way to store in the database.
 
Bear Bibeault
Sheriff
Posts: 67619
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which, in itself, is rather bizarre. What are you storing it for? What is it from the response you want to store? Why?

When you're doing something really bizarre, it's best to give full details.
reply
    Bookmark Topic Watch Topic
  • New Topic