Forums Register Login

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

+Pie Number of slices to send: Send
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.


+Pie Number of slices to send: Send
I asked this in the other post. Please explicitly define what you are trying to save to the DB (and why!)
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
"save the request" is completely ambiguous. I have no idea what you are saving.
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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?

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4687 times.
Similar Threads
Why request dispatcher is not sending querystring to jsp?
Need Help With Accessing Multiple Access Database Tables Using JSP
sending space separated string in sendRedirect
Get the URL of the page being redirected to?
How to create ConfirmServlet using a JavaMail / Servlet Mechanism?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:25:20.