Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Biswajit Das
application/pdf is not a supported mime type
July 19, 2013 4:06 AM

Biswajit Das

Rank: New Member

Posts: 1

Join Date: July 19, 2013

Recent Posts


I am new to Liferay. I am using struts2 in Liferay 6.1 to develop a application and tomcat as server. I have a download link in the jsp which should download a pdf file from the server.

My jsp page is contains the following:

2   <a href='<s:url action='download'> </s:url>'>
3         Download PDF</a>

My struts.xml is:

1<action name="download" class="com.stp.portal.view.DownloadAction">
2            <result name="success" type="stream">
3                <param name="contentType">application/pdf</param>
4                <param name="inputName">fileInputStream</param>
5                <param name="contentDisposition">attachment;filename="abc.pdf"</param>
6                <param name="bufferSize">1024</param>
7            </result>
8        </action>

My Action class is:

 1public class DownloadAction extends ActionSupport{
 3    private InputStream fileInputStream;
 5    public InputStream getFileInputStream() {
 6        return fileInputStream;
 7    }
 9    public String execute() throws Exception {
12        fileInputStream = new FileInputStream(new File("D:\\abc.pdf"));
13        return "success";
14    }

But when I click on the download link, I get the following error:

1ERROR [Jsr168Dispatcher:38] Could not execute action
2java.lang.IllegalArgumentException: application/pdf is not a supported mime type
3    at com.liferay.portlet.MimeResponseImpl.setContentType(

I dont know how to solve this issue. I have googled it to find solution, bt didnot work out for me. Is this because i am using Jsr168Dispatcher? If I use Jsr268Dispatcher will it be solved ? (I found it somehere, but dont know how to change to Jsr268Dispatcher). I am stuck here. Any help is highly appreciating.
Vishal Panchal
RE: application/pdf is not a supported mime type
July 19, 2013 6:03 AM

Vishal Panchal

Rank: Expert

Posts: 279

Join Date: May 20, 2012

Recent Posts

Hi Biswajit,

AFAIK you have to set your contentType as application/pdf in your DownloadAction.

write below line before return "success" in your DownloadAction.


you can take reference of below post as well.

hope it helps.!

Thank you,
Vishal Panchal