• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Calling a servlet from portlet?

Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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());

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

please suggest me a solution

K.Kiran Kumar
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic