WebSphere Portal Server - File download using a servlet: Problems with the generated URL

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > June 2006 > File download using a servlet: Problems with the generated URL





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author File download using a servlet: Problems with the generated URL

2006-06-28, 7:21 pm

Hello, fellows.
I'm trying to implement a file download functionality in an IBM Struts Portlet. I've read several posts on the subject and I decided to go to the servlet option. However, I've not found any tested and reliable code that does that and I've not even success
fully generate the URL to the servlet. It's been 3 days and no luck!

This is my progress so far:
I was able to add the servlet to my portlet project. Code fragment in the Web.xml:

<web-app id="WebApp">
...
<servlet id="Servlet_2">
<servlet-name>FileDownloadServlet</servlet-name>
<display-name>FileDownloadServlet</display-name>
<servlet-class>com.gedas.omegaq.docmgr.servlet.FileDownloadServlet</servlet-class>
</servlet>
...
<servlet-mapping>
<servlet-name>FileDownloadServlet</servlet-name>
<url-pattern>/FileDownloadServlet</url-pattern>
</servlet-mapping>

Note: The webapp is the same that contains the WpsStrutsPortlet.

And in my JSP I coded the following:

<html:link page='<%=response.encodeURL("FileDownloadServlet")%>'>A File</html:link>

The generated URL stills contains portlet context and therefore it doesn't reach the servlet:

http://localhost:9081/wps/myportal/!ut/p/_s.7_0_A/7_0_16IE/.cmd/ad/.ar/sa.spf_ActionListener/.c/6_0_16FA/.ce/7_0_16IG/.p/5_0_16C5/.d/2?PC_7_0_16IG_spf_strutsAction=%212f. OMQ_PSA_Definition%212fFileDownloadServl
et#7_0_16IG

I've read in a topic that the request and response objects should not be the portlet ones but I've not found any reference on how to do that.

Any help or reference will be enormously appreciated.
Best regards!

2006-06-30, 7:27 am

I am using render response to do this in my portlet. I think this should also
work in the JSP.

String url = response.encodeURL( request.getContextPath() +
"/Servlet");

Thanks,
Mohan

2006-06-30, 7:22 pm

Hello, Mohan.
I decided to implement the servlet in a separate WAR project and to call it directly using the HTML anchor tag as following:

<a href="/FileDownload/FileDownloadServlet">Something</a>

That finally worked. Thanks anyway!
Cheerz,
Azbel.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com