2 Portlet Specs and URL encoding…
Still working on the file upload portlet for my current client. I’ve decided to change gears and parse the request in a servlet rather than the portlet itself. Why? I think it will allow me to create a second form on the Portlet’s JSP and encode it in whatever way I need.
The portlet complies with JSR168, not the WebSphere portlet API. Seeing as it’s portal, I need to encode the URL to the servlet…easy enough.
and pass this variable into the form’s action attribute and I’m done.
…except…I get a “Page Not Found” error and the following shows up on the console:
Servlet Request Processor Exception: Virtual Host/WebGroup Not Found ….
So I could go into everything I tried in figuring out why this very simple little example didn’t work but I’ll save you the time and anguish. Turns out the IBM’er beside the IBM’er I was working with knew what the issue was….had he chimed in a little earlier (hint for the future Jimmy), we would have saved a little grief but I’m still grateful for his involvement.
Turns out a JSR168 portlet needs an additional bit of magic to encode a url. You need to use the following:
String servletURL=response.encodeURL(renderRequest.getContextPath()+ "/UploadServlet");
with renderRequest doing the heavy lifting. Add that and you’re gold.
Originally published at http://jamiemcilroy.wordpress.com on October 4, 2006.