| Author |
Posting from inside a portlet?
|
|
|
| Hi! I'm trying to do a POST request from inside a JSR168 portlet. I create a HttpURLConnection object and write to it using an OutputStreamWriter. On the other side (in another JVM) I have a servlet that receives the posted data. However, I can't get it w
orking. It seems my servlet does not receive any HTTP request what so ever (I can see a TCP connection beeing established though). Is this impossible to do from inside a portlet? Thanks from a newbie!
| |
| Aaron A'brook 2006-09-16, 1:48 pm |
| I'm fairly new to J2EE (Only a few months of dev) but this 'should' be possible.
I'm curious. Do you have a doPost() within the servlet you are calling?
| |
|
| Thanks for your reply Aaron! Yes, I do have a doPost() method within my servlet. I actually solved this problem yesterday, and if someone is interested in the "solution", you need to fully process the InputStream of the HttpURLConnection as well. Since I
was only interested in sending the data I didn't bother to process the InputStream, but that was obviously a big "No no!".
I don't know if this processing is bad design. I saw that the portal provides a service called "ContentAccessService" which could be used to access remote systems. Perhaps using this portlet service would be a better approach...? But anyway, this seems to
work for my need.
| |
| Aaron A'brook 2006-09-18, 1:30 am |
| That makes sense seeing how post does not set parameters on a url but within the body of the html packet being sent.
I'm glad you got it sorted.
|
|
|
|