Question

I'm a little unfamiliar both with the Servlet API and Apache Http Components.

I need to handle an incoming POST request with unknown data (although probably the result of a form submission) using HttpServlet.doPost() which I've implemented, and request the same posted information from another URL, effectively acting as a relay for the HTTP POST. I then need to convert the response to a String (it will be text/html) and process it further before returning it to the web browser that requested it from me.

Due to my unfamiliarity with these libraries, its not clear to me how to handle issues like the content-type of the posted data, and also avoiding any problems due to neglecting to release resources.

Can anyone provide any pointers on this?

Was it helpful?

Solution

You should start by having a look at HttpClient class from apache API. It will handle both get and posts as needed and later you could feel its request with the data you receive in your own servlet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top