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.

String servletURL=response.encodeURL("/UploadServlet");

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 ….

hmmm

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.

Advertisements

9 thoughts on “2 Portlet Specs and URL encoding…

  1. Hi, I just want to know how you implemented this. Did you use the JSF tag hx:fileupload?
    What about the form used in the JSP… did you use an encoding type (e.g. multipart)?

  2. Heya i’m for the primary time here. I came across this board and I find It really helpful & it helped me out much. I’m
    hoping to provide something again and aid others such as you aided me.

  3. Usually I don’t learn post on blogs, but I wish to say that this write-up very forced me to try and do it! Your writing style has been surprised me. Thank you, very nice article.

  4. Good day! I could have sworn I’ve visited this web site before but after browsing through some of the articles I realized it’s new to me.
    Anyways, I’m definitely happy I came across it and I’ll be bookmarking it and checking
    back frequently!

  5. The ones who liked it all had nutritionists prior to and the plan really worked
    properly for them so they cut down on going to their
    nutritionist.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s