• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a servlet from portlet?

 
kasyaparushi kiran
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Below code i have added in doView() method

Servlet Name is DownloadServlet , url pattern also DownloadServlet

StringBuffer buf = new StringBuffer(response.encodeURL(request.getContextPath()+ "/servlet/DownloadServlet"));

PortletRequestDispatcher rd=getPortletContext().getRequestDispatcher(buf.toString());
rd.include(request,response);

It is throwing FileNot found exception (404).I checked in web.xml also.

please suggest me a solution

Thanks,
K.Kiran Kumar
 
sijju ju
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't serve a content type other that of the portal from a portlet. you can imagine why. a page can only have one content type, so the portal allow each portal to set the content type.

i'm also confused because i see the link you have is directly to the servlet, but the code snippet shows you calling PortletDispatcher.include(). how is the portlet getting invoked if the link is directly to the servlet?

regardless, what you want to do is to use the JSR-286 serveResource() method. see the specspec for more details.
==================================
internet access provider
Thailand Travel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic