You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com> on 2021/01/12 19:48:13 UTC

Tomcat server not considering Mime Type - Request urgent help!!

Hi Team

We have an application deployed in tomcat9.0.38 server which generates an xls file dynamically and saves at server end. When we try to access the file using application frontend, it is neither showing up in excel format  nor showing up pop up to save the file instead it is showing the content of xls file in xml format directly on the browser.

Below mime type is set both at web.xml of webapplicatio end and as well as Tomcat9038/conf/web.xml

<mime-mapping>
    <extension>xls</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>

Could you please help in resolving the issue ASAP


Thanks
Swathi

Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Niranjan Rao <nh...@gmail.com>.
What everyone is telling you is browser is not seeing right headers..

You can modify your tomcat settings as well as apache2 settings to log 
outgoing content type header. If tomcat and apache2 headers match, 
problem is in your tomcat side. If there is a mismatch and tomcat is 
sending right headers. then problem is on apache2 side. You can directly 
connect to tomact using curl or even in the browser to bypass apache2 
and see if it works.

How is response returned? How do you set the extension of the file? You 
said file generated dynamically, are you sure your servlet or whatever 
service handler you have there is not sending incorrect header?

I am not sure, but I believe global mime type settings are only for 
static files that tomcat serves. Any dynamically generated content has 
to be managed by response handler. More knowledgeable people here can 
correct me if I am wrong.

Regards,

Niranjan

On 1/14/21 8:59 AM, Jonnalagadda, Swathi (External) wrote:
> Could you please elaborate more on this as to where I need to check
> ________________________________
> From: Mounika Reddy <sp...@gmail.com>
> Sent: Thursday, January 14, 2021 2:41 AM
> To: Tomcat Users List <us...@tomcat.apache.org>
> Cc: Mark Thomas <ma...@apache.org>
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
>
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> If you are via AJP connector, then check if Apache proxy is changing
> headers. We have a similar environment and when we set content-type,
> clients see the same but possible it must be overriding
>
> On Wed, Jan 13, 2021, 3:14 PM Jonnalagadda, Swathi (External) <
> Swathi.Jonnalagadda@xerox.com> wrote:
>
>> This issue is not resolved yet.  The extension of file is clearly .xls but
>> I see content-type in response header is set to text/html.
>>
>> Please note that the request initially hits apache2.4 server which is
>> redirected to tomcat9 server after successful authentication at siteminder.
>>
>> The connection is configured via ajp connector.
>>
>> Is there a possibility that the apache server is overwriting the
>> content-type header in response ?
>>
>> Please advise.
>>
>> Thanks
>> Swathi
>>
>> -----Original Message-----
>> From: Jonnalagadda, Swathi (External) [mailto:
>> Swathi.Jonnalagadda@xerox.com]
>> Sent: Wednesday, January 13, 2021 1:57 PM
>> To: Tomcat Users List
>> Cc: Mark Thomas
>> Subject: RE: Tomcat server not considering Mime Type - Request urgent
>> help!!
>>
>> CAUTION:   This email originated from outside the organization. Do not
>> click links or open attachments unless you recognize the sender and know
>> the content is safe.
>>
>> Thank you for the email
>>
>> We could see that when we try to open the xls file separately the browser
>> shows dialogue box to save it so it is nothing to do with browser settings
>>
>> Could you please advise if I am missing out any setting here.
>>
>> Thanks
>> Swathi
>> -----Original Message-----
>> From: Mounika Reddy [mailto:spidermain12@gmail.com]
>> Sent: Wednesday, January 13, 2021 3:48 AM
>> To: Tomcat Users List
>> Cc: Mark Thomas
>> Subject: Re: Tomcat server not considering Mime Type - Request urgent
>> help!!
>>
>> CAUTION:   This email originated from outside the organization. Do not
>> click links or open attachments unless you recognize the sender and know
>> the content is safe.
>>
>> Pls check http response headers for the request to confirm if it's
>> returning proper headers.
>>
>> Once they are in place then it may be to do with browser settings not
>> processing headers.
>>
>>
>>
>> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) <
>> Swathi.Jonnalagadda@xerox.com> wrote:
>>
>>> Hi Team
>>>
>>> We have an application deployed in tomcat9.0.38 server which generates
>>> an xls file dynamically and saves at server end. When we try to access
>>> the file using application frontend, it is neither showing up in excel
>>> format nor showing up pop up to save the file instead it is showing
>>> the content of xls file in xml format directly on the browser.
>>>
>>> Below mime type is set both at web.xml of webapplicatio end and as
>>> well as Tomcat9038/conf/web.xml
>>>
>>> <mime-mapping>
>>>      <extension>xls</extension>
>>>      <mime-type>application/vnd.ms-excel</mime-type>
>>>      </mime-mapping>
>>>
>>> Could you please help in resolving the issue ASAP
>>>
>>>
>>> Thanks
>>> Swathi
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com>.
Could you please elaborate more on this as to where I need to check
________________________________
From: Mounika Reddy <sp...@gmail.com>
Sent: Thursday, January 14, 2021 2:41 AM
To: Tomcat Users List <us...@tomcat.apache.org>
Cc: Mark Thomas <ma...@apache.org>
Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

If you are via AJP connector, then check if Apache proxy is changing
headers. We have a similar environment and when we set content-type,
clients see the same but possible it must be overriding

On Wed, Jan 13, 2021, 3:14 PM Jonnalagadda, Swathi (External) <
Swathi.Jonnalagadda@xerox.com> wrote:

> This issue is not resolved yet.  The extension of file is clearly .xls but
> I see content-type in response header is set to text/html.
>
> Please note that the request initially hits apache2.4 server which is
> redirected to tomcat9 server after successful authentication at siteminder.
>
> The connection is configured via ajp connector.
>
> Is there a possibility that the apache server is overwriting the
> content-type header in response ?
>
> Please advise.
>
> Thanks
> Swathi
>
> -----Original Message-----
> From: Jonnalagadda, Swathi (External) [mailto:
> Swathi.Jonnalagadda@xerox.com]
> Sent: Wednesday, January 13, 2021 1:57 PM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: RE: Tomcat server not considering Mime Type - Request urgent
> help!!
>
> CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Thank you for the email
>
> We could see that when we try to open the xls file separately the browser
> shows dialogue box to save it so it is nothing to do with browser settings
>
> Could you please advise if I am missing out any setting here.
>
> Thanks
> Swathi
> -----Original Message-----
> From: Mounika Reddy [mailto:spidermain12@gmail.com]
> Sent: Wednesday, January 13, 2021 3:48 AM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: Re: Tomcat server not considering Mime Type - Request urgent
> help!!
>
> CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Pls check http response headers for the request to confirm if it's
> returning proper headers.
>
> Once they are in place then it may be to do with browser settings not
> processing headers.
>
>
>
> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) <
> Swathi.Jonnalagadda@xerox.com> wrote:
>
> > Hi Team
> >
> > We have an application deployed in tomcat9.0.38 server which generates
> > an xls file dynamically and saves at server end. When we try to access
> > the file using application frontend, it is neither showing up in excel
> > format nor showing up pop up to save the file instead it is showing
> > the content of xls file in xml format directly on the browser.
> >
> > Below mime type is set both at web.xml of webapplicatio end and as
> > well as Tomcat9038/conf/web.xml
> >
> > <mime-mapping>
> >     <extension>xls</extension>
> >     <mime-type>application/vnd.ms-excel</mime-type>
> >     </mime-mapping>
> >
> > Could you please help in resolving the issue ASAP
> >
> >
> > Thanks
> > Swathi
> >
>

Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Mounika Reddy <sp...@gmail.com>.
If you are via AJP connector, then check if Apache proxy is changing
headers. We have a similar environment and when we set content-type,
clients see the same but possible it must be overriding

On Wed, Jan 13, 2021, 3:14 PM Jonnalagadda, Swathi (External) <
Swathi.Jonnalagadda@xerox.com> wrote:

> This issue is not resolved yet.  The extension of file is clearly .xls but
> I see content-type in response header is set to text/html.
>
> Please note that the request initially hits apache2.4 server which is
> redirected to tomcat9 server after successful authentication at siteminder.
>
> The connection is configured via ajp connector.
>
> Is there a possibility that the apache server is overwriting the
> content-type header in response ?
>
> Please advise.
>
> Thanks
> Swathi
>
> -----Original Message-----
> From: Jonnalagadda, Swathi (External) [mailto:
> Swathi.Jonnalagadda@xerox.com]
> Sent: Wednesday, January 13, 2021 1:57 PM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: RE: Tomcat server not considering Mime Type - Request urgent
> help!!
>
> CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Thank you for the email
>
> We could see that when we try to open the xls file separately the browser
> shows dialogue box to save it so it is nothing to do with browser settings
>
> Could you please advise if I am missing out any setting here.
>
> Thanks
> Swathi
> -----Original Message-----
> From: Mounika Reddy [mailto:spidermain12@gmail.com]
> Sent: Wednesday, January 13, 2021 3:48 AM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: Re: Tomcat server not considering Mime Type - Request urgent
> help!!
>
> CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Pls check http response headers for the request to confirm if it's
> returning proper headers.
>
> Once they are in place then it may be to do with browser settings not
> processing headers.
>
>
>
> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) <
> Swathi.Jonnalagadda@xerox.com> wrote:
>
> > Hi Team
> >
> > We have an application deployed in tomcat9.0.38 server which generates
> > an xls file dynamically and saves at server end. When we try to access
> > the file using application frontend, it is neither showing up in excel
> > format nor showing up pop up to save the file instead it is showing
> > the content of xls file in xml format directly on the browser.
> >
> > Below mime type is set both at web.xml of webapplicatio end and as
> > well as Tomcat9038/conf/web.xml
> >
> > <mime-mapping>
> >     <extension>xls</extension>
> >     <mime-type>application/vnd.ms-excel</mime-type>
> >     </mime-mapping>
> >
> > Could you please help in resolving the issue ASAP
> >
> >
> > Thanks
> > Swathi
> >
>

RE: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com>.
This issue is not resolved yet.  The extension of file is clearly .xls but I see content-type in response header is set to text/html. 

Please note that the request initially hits apache2.4 server which is redirected to tomcat9 server after successful authentication at siteminder. 

The connection is configured via ajp connector.

Is there a possibility that the apache server is overwriting the content-type header in response ?

Please advise.

Thanks
Swathi 

-----Original Message-----
From: Jonnalagadda, Swathi (External) [mailto:Swathi.Jonnalagadda@xerox.com] 
Sent: Wednesday, January 13, 2021 1:57 PM
To: Tomcat Users List
Cc: Mark Thomas
Subject: RE: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Thank you for the email

We could see that when we try to open the xls file separately the browser shows dialogue box to save it so it is nothing to do with browser settings

Could you please advise if I am missing out any setting here.

Thanks
Swathi
-----Original Message-----
From: Mounika Reddy [mailto:spidermain12@gmail.com]
Sent: Wednesday, January 13, 2021 3:48 AM
To: Tomcat Users List
Cc: Mark Thomas
Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Pls check http response headers for the request to confirm if it's returning proper headers.

Once they are in place then it may be to do with browser settings not processing headers.



On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:

> Hi Team
>
> We have an application deployed in tomcat9.0.38 server which generates 
> an xls file dynamically and saves at server end. When we try to access 
> the file using application frontend, it is neither showing up in excel 
> format nor showing up pop up to save the file instead it is showing 
> the content of xls file in xml format directly on the browser.
>
> Below mime type is set both at web.xml of webapplicatio end and as 
> well as Tomcat9038/conf/web.xml
>
> <mime-mapping>
>     <extension>xls</extension>
>     <mime-type>application/vnd.ms-excel</mime-type>
>     </mime-mapping>
>
> Could you please help in resolving the issue ASAP
>
>
> Thanks
> Swathi
>

Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Greg Huber <gr...@gmail.com>.
I have found getting browsers to handle objects correctly is problematic 
and needs to be specific to the use case in the html link.

<object id="media" data="..." type="application/vnd.ms-excel"></object>

On 13/01/2021 08:27, Jonnalagadda, Swathi (External) wrote:
> Thank you for the email
>
> We could see that when we try to open the xls file separately the browser shows dialogue box to save it so it is nothing to do with browser settings
>
> Could you please advise if I am missing out any setting here.
>
> Thanks
> Swathi
> -----Original Message-----
> From: Mounika Reddy [mailto:spidermain12@gmail.com]
> Sent: Wednesday, January 13, 2021 3:48 AM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
>
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> Pls check http response headers for the request to confirm if it's returning proper headers.
>
> Once they are in place then it may be to do with browser settings not processing headers.
>
>
>
> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:
>
>> Hi Team
>>
>> We have an application deployed in tomcat9.0.38 server which generates
>> an xls file dynamically and saves at server end. When we try to access
>> the file using application frontend, it is neither showing up in excel
>> format nor showing up pop up to save the file instead it is showing
>> the content of xls file in xml format directly on the browser.
>>
>> Below mime type is set both at web.xml of webapplicatio end and as
>> well as Tomcat9038/conf/web.xml
>>
>> <mime-mapping>
>>      <extension>xls</extension>
>>      <mime-type>application/vnd.ms-excel</mime-type>
>>      </mime-mapping>
>>
>> Could you please help in resolving the issue ASAP
>>
>>
>> Thanks
>> Swathi
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
Hi again.
Sorry for the noise.
The page which you quoted 
(https://www.geeksforgeeks.org/http-headers-content-disposition/), itself contains a 
formal reference to
RFC 5987 (https://tools.ietf.org/html/rfc5987), which formally defines the extended 
"filename*" header parameter below.

On 15.01.2021 11:48, André Warnier (tomcat/perl) wrote:
> On 14.01.2021 22:55, Christopher Schultz wrote:
>> Content-Disposition: attachment; filename="[filename]"; filename*=utf-8''[filename in 
>> UTF-8 encoding]
> 
> Hi Chris.
> Do you have any reference for the above ?
> (the "utf8''" part is new to me)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "André Warnier (tomcat/perl)" <aw...@ice-sa.com>.
On 14.01.2021 22:55, Christopher Schultz wrote:
> Content-Disposition: attachment; filename="[filename]"; filename*=utf-8''[filename in 
> UTF-8 encoding]

Hi Chris.
Do you have any reference for the above ?
(the "utf8''" part is new to me)


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com>.
Hi Schultz

Please find sample code below
Suffix is there in request so ..

RequestDispatcher rd = context.getRequestDispatcher(sample.xls);
			String contentType =((request.getParameter(SUFFIX) !=null) && ((request.getParameter(SUFFIX).equalsIgnoreCase("xls")))) ?"application/vnd.ms-excel":null; <--- setting explicitly
			if (contentType != null)
			{
				response.setContentType(contentType);
			}
			rd.forward(request, response);

Thanks
Swathi

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, January 15, 2021 7:41 PM
To: users@tomcat.apache.org
Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Swathi,

On 1/15/21 08:41, Jonnalagadda, Swathi (External) wrote:
> My web application is trying to open the xls file by passing the file 
> to request.getDispatcher method. It is supposed open up download 
> dialogue box but it is not doing.
After you get a request dispatcher, what are you doing with it?

> If I set the content-type explicitly to response it is showing up the box.

Please post actual code.

> With Tomcat 7 it was never an issue and it used to consider mimetype 
> that is defined in web.xml but in Tomcat 9 not sure why it is not 
> considering mime-type.

Something seems odd, here. Post your sample code.

-chris

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, January 15, 2021 3:25 AM
> To: users@tomcat.apache.org
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
> 
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> Swathi,
> 
> On 1/13/21 03:27, Jonnalagadda, Swathi (External) wrote:
>> We could see that when we try to open the xls file separately the 
>> browser shows dialogue box to save it so it is nothing to do with 
>> browser settings
> What is the difference between "open[ing] the XLS file separately" and ... whatever your application is doing instead?
> 
> If you want to force a download, you need to add some response headers otherwise a normal browser will usually try to render the file in the browser window instead of initiating a download.
> 
> The response header you need is "Content-Disposition" and its value can be complex. Here is what I usually do:
> 
> Content-Disposition: attachment; filename="[filename]"; 
> filename*=utf-8''[filename in UTF-8 encoding]
> 
> Note that the above is all on one line and the two single-quotes are not a typo. You will also need to escape any double-quotes in the "filename"
> and escape any semicolons in the utf8-filename.
> 
> You can find more information here as well as other places online:
> https://www.geeksforgeeks.org/http-headers-content-disposition/
> 
> The above reference happens to be particularly thorough, even moreso than Mozilla's (typically very good and complete) documentation for Content-Disposition.
> 
> If your application is not being hosted within a web browser (e.g. it's a mobile application, or an Electron (etc.) application, etc.) then it's entirely up to you to trigger the display of a download dialog when this kind of thing needs to happen.
> 
> -chris
> 
>> -----Original Message-----
>> From: Mounika Reddy [mailto:spidermain12@gmail.com]
>> Sent: Wednesday, January 13, 2021 3:48 AM
>> To: Tomcat Users List
>> Cc: Mark Thomas
>> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
>>
>> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>
>> Pls check http response headers for the request to confirm if it's returning proper headers.
>>
>> Once they are in place then it may be to do with browser settings not processing headers.
>>
>>
>>
>> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:
>>
>>> Hi Team
>>>
>>> We have an application deployed in tomcat9.0.38 server which 
>>> generates an xls file dynamically and saves at server end. When we 
>>> try to access the file using application frontend, it is neither 
>>> showing up in excel format nor showing up pop up to save the file 
>>> instead it is showing the content of xls file in xml format directly on the browser.
>>>
>>> Below mime type is set both at web.xml of webapplicatio end and as 
>>> well as Tomcat9038/conf/web.xml
>>>
>>> <mime-mapping>
>>>       <extension>xls</extension>
>>>       <mime-type>application/vnd.ms-excel</mime-type>
>>>       </mime-mapping>
>>>
>>> Could you please help in resolving the issue ASAP
>>>
>>>
>>> Thanks
>>> Swathi
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Swathi,

On 1/15/21 08:41, Jonnalagadda, Swathi (External) wrote:
> My web application is trying to open the xls file by passing the file
> to request.getDispatcher method. It is supposed open up download
> dialogue box but it is not doing.
After you get a request dispatcher, what are you doing with it?

> If I set the content-type explicitly to response it is showing up the box.

Please post actual code.

> With Tomcat 7 it was never an issue and it used to consider mimetype
> that is defined in web.xml but in Tomcat 9 not sure why it is not
> considering mime-type.

Something seems odd, here. Post your sample code.

-chris

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, January 15, 2021 3:25 AM
> To: users@tomcat.apache.org
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
> 
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> Swathi,
> 
> On 1/13/21 03:27, Jonnalagadda, Swathi (External) wrote:
>> We could see that when we try to open the xls file separately the
>> browser shows dialogue box to save it so it is nothing to do with
>> browser settings
> What is the difference between "open[ing] the XLS file separately" and ... whatever your application is doing instead?
> 
> If you want to force a download, you need to add some response headers otherwise a normal browser will usually try to render the file in the browser window instead of initiating a download.
> 
> The response header you need is "Content-Disposition" and its value can be complex. Here is what I usually do:
> 
> Content-Disposition: attachment; filename="[filename]"; filename*=utf-8''[filename in UTF-8 encoding]
> 
> Note that the above is all on one line and the two single-quotes are not a typo. You will also need to escape any double-quotes in the "filename"
> and escape any semicolons in the utf8-filename.
> 
> You can find more information here as well as other places online:
> https://www.geeksforgeeks.org/http-headers-content-disposition/
> 
> The above reference happens to be particularly thorough, even moreso than Mozilla's (typically very good and complete) documentation for Content-Disposition.
> 
> If your application is not being hosted within a web browser (e.g. it's a mobile application, or an Electron (etc.) application, etc.) then it's entirely up to you to trigger the display of a download dialog when this kind of thing needs to happen.
> 
> -chris
> 
>> -----Original Message-----
>> From: Mounika Reddy [mailto:spidermain12@gmail.com]
>> Sent: Wednesday, January 13, 2021 3:48 AM
>> To: Tomcat Users List
>> Cc: Mark Thomas
>> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
>>
>> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
>>
>> Pls check http response headers for the request to confirm if it's returning proper headers.
>>
>> Once they are in place then it may be to do with browser settings not processing headers.
>>
>>
>>
>> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:
>>
>>> Hi Team
>>>
>>> We have an application deployed in tomcat9.0.38 server which
>>> generates an xls file dynamically and saves at server end. When we
>>> try to access the file using application frontend, it is neither
>>> showing up in excel format nor showing up pop up to save the file
>>> instead it is showing the content of xls file in xml format directly on the browser.
>>>
>>> Below mime type is set both at web.xml of webapplicatio end and as
>>> well as Tomcat9038/conf/web.xml
>>>
>>> <mime-mapping>
>>>       <extension>xls</extension>
>>>       <mime-type>application/vnd.ms-excel</mime-type>
>>>       </mime-mapping>
>>>
>>> Could you please help in resolving the issue ASAP
>>>
>>>
>>> Thanks
>>> Swathi
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Mounika Reddy <sp...@gmail.com>.
As Niranjan said, pls validate the headers first and it may be not the case
in Tomcat7 but there are multiple points which must have updated probably
triggering it. Only way to verify is set Content-Disposition header
accurately and verify if browser can see it

On Fri, Jan 15, 2021, 8:41 AM Jonnalagadda, Swathi (External) <
Swathi.Jonnalagadda@xerox.com> wrote:

> Hi Chris
>
> My web application is trying to open the xls file by passing the file to
> request.getDispatcher method. It is supposed open up download dialogue box
> but it is not doing.
>
> If I set the content-type explicitly to response it is showing up the box.
>
> With Tomcat 7 it was never an issue and it used to consider mimetype that
> is defined in web.xml but in Tomcat 9 not sure why it is not considering
> mime-type.
>
> Thanks
> Swathi
>
> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, January 15, 2021 3:25 AM
> To: users@tomcat.apache.org
> Subject: Re: Tomcat server not considering Mime Type - Request urgent
> help!!
>
> CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
>
> Swathi,
>
> On 1/13/21 03:27, Jonnalagadda, Swathi (External) wrote:
> > We could see that when we try to open the xls file separately the
> > browser shows dialogue box to save it so it is nothing to do with
> > browser settings
> What is the difference between "open[ing] the XLS file separately" and ...
> whatever your application is doing instead?
>
> If you want to force a download, you need to add some response headers
> otherwise a normal browser will usually try to render the file in the
> browser window instead of initiating a download.
>
> The response header you need is "Content-Disposition" and its value can be
> complex. Here is what I usually do:
>
> Content-Disposition: attachment; filename="[filename]";
> filename*=utf-8''[filename in UTF-8 encoding]
>
> Note that the above is all on one line and the two single-quotes are not a
> typo. You will also need to escape any double-quotes in the "filename"
> and escape any semicolons in the utf8-filename.
>
> You can find more information here as well as other places online:
> https://www.geeksforgeeks.org/http-headers-content-disposition/
>
> The above reference happens to be particularly thorough, even moreso than
> Mozilla's (typically very good and complete) documentation for
> Content-Disposition.
>
> If your application is not being hosted within a web browser (e.g. it's a
> mobile application, or an Electron (etc.) application, etc.) then it's
> entirely up to you to trigger the display of a download dialog when this
> kind of thing needs to happen.
>
> -chris
>
> > -----Original Message-----
> > From: Mounika Reddy [mailto:spidermain12@gmail.com]
> > Sent: Wednesday, January 13, 2021 3:48 AM
> > To: Tomcat Users List
> > Cc: Mark Thomas
> > Subject: Re: Tomcat server not considering Mime Type - Request urgent
> help!!
> >
> > CAUTION:   This email originated from outside the organization. Do not
> click links or open attachments unless you recognize the sender and know
> the content is safe.
> >
> > Pls check http response headers for the request to confirm if it's
> returning proper headers.
> >
> > Once they are in place then it may be to do with browser settings not
> processing headers.
> >
> >
> >
> > On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) <
> Swathi.Jonnalagadda@xerox.com> wrote:
> >
> >> Hi Team
> >>
> >> We have an application deployed in tomcat9.0.38 server which
> >> generates an xls file dynamically and saves at server end. When we
> >> try to access the file using application frontend, it is neither
> >> showing up in excel format nor showing up pop up to save the file
> >> instead it is showing the content of xls file in xml format directly on
> the browser.
> >>
> >> Below mime type is set both at web.xml of webapplicatio end and as
> >> well as Tomcat9038/conf/web.xml
> >>
> >> <mime-mapping>
> >>      <extension>xls</extension>
> >>      <mime-type>application/vnd.ms-excel</mime-type>
> >>      </mime-mapping>
> >>
> >> Could you please help in resolving the issue ASAP
> >>
> >>
> >> Thanks
> >> Swathi
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

RE: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com>.
Hi Chris

My web application is trying to open the xls file by passing the file to request.getDispatcher method. It is supposed open up download dialogue box but it is not doing.

If I set the content-type explicitly to response it is showing up the box.

With Tomcat 7 it was never an issue and it used to consider mimetype that is defined in web.xml but in Tomcat 9 not sure why it is not considering mime-type.

Thanks
Swathi 

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Friday, January 15, 2021 3:25 AM
To: users@tomcat.apache.org
Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Swathi,

On 1/13/21 03:27, Jonnalagadda, Swathi (External) wrote:
> We could see that when we try to open the xls file separately the 
> browser shows dialogue box to save it so it is nothing to do with 
> browser settings
What is the difference between "open[ing] the XLS file separately" and ... whatever your application is doing instead?

If you want to force a download, you need to add some response headers otherwise a normal browser will usually try to render the file in the browser window instead of initiating a download.

The response header you need is "Content-Disposition" and its value can be complex. Here is what I usually do:

Content-Disposition: attachment; filename="[filename]"; filename*=utf-8''[filename in UTF-8 encoding]

Note that the above is all on one line and the two single-quotes are not a typo. You will also need to escape any double-quotes in the "filename" 
and escape any semicolons in the utf8-filename.

You can find more information here as well as other places online:
https://www.geeksforgeeks.org/http-headers-content-disposition/

The above reference happens to be particularly thorough, even moreso than Mozilla's (typically very good and complete) documentation for Content-Disposition.

If your application is not being hosted within a web browser (e.g. it's a mobile application, or an Electron (etc.) application, etc.) then it's entirely up to you to trigger the display of a download dialog when this kind of thing needs to happen.

-chris

> -----Original Message-----
> From: Mounika Reddy [mailto:spidermain12@gmail.com]
> Sent: Wednesday, January 13, 2021 3:48 AM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
> 
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> Pls check http response headers for the request to confirm if it's returning proper headers.
> 
> Once they are in place then it may be to do with browser settings not processing headers.
> 
> 
> 
> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:
> 
>> Hi Team
>>
>> We have an application deployed in tomcat9.0.38 server which 
>> generates an xls file dynamically and saves at server end. When we 
>> try to access the file using application frontend, it is neither 
>> showing up in excel format nor showing up pop up to save the file 
>> instead it is showing the content of xls file in xml format directly on the browser.
>>
>> Below mime type is set both at web.xml of webapplicatio end and as 
>> well as Tomcat9038/conf/web.xml
>>
>> <mime-mapping>
>>      <extension>xls</extension>
>>      <mime-type>application/vnd.ms-excel</mime-type>
>>      </mime-mapping>
>>
>> Could you please help in resolving the issue ASAP
>>
>>
>> Thanks
>> Swathi
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Swathi,

On 1/13/21 03:27, Jonnalagadda, Swathi (External) wrote:
> We could see that when we try to open the xls file separately the
> browser shows dialogue box to save it so it is nothing to do with
> browser settings
What is the difference between "open[ing] the XLS file separately" and 
... whatever your application is doing instead?

If you want to force a download, you need to add some response headers 
otherwise a normal browser will usually try to render the file in the 
browser window instead of initiating a download.

The response header you need is "Content-Disposition" and its value can 
be complex. Here is what I usually do:

Content-Disposition: attachment; filename="[filename]"; 
filename*=utf-8''[filename in UTF-8 encoding]

Note that the above is all on one line and the two single-quotes are not 
a typo. You will also need to escape any double-quotes in the "filename" 
and escape any semicolons in the utf8-filename.

You can find more information here as well as other places online:
https://www.geeksforgeeks.org/http-headers-content-disposition/

The above reference happens to be particularly thorough, even moreso 
than Mozilla's (typically very good and complete) documentation for 
Content-Disposition.

If your application is not being hosted within a web browser (e.g. it's 
a mobile application, or an Electron (etc.) application, etc.) then it's 
entirely up to you to trigger the display of a download dialog when this 
kind of thing needs to happen.

-chris

> -----Original Message-----
> From: Mounika Reddy [mailto:spidermain12@gmail.com]
> Sent: Wednesday, January 13, 2021 3:48 AM
> To: Tomcat Users List
> Cc: Mark Thomas
> Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!
> 
> CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> Pls check http response headers for the request to confirm if it's returning proper headers.
> 
> Once they are in place then it may be to do with browser settings not processing headers.
> 
> 
> 
> On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:
> 
>> Hi Team
>>
>> We have an application deployed in tomcat9.0.38 server which generates
>> an xls file dynamically and saves at server end. When we try to access
>> the file using application frontend, it is neither showing up in excel
>> format nor showing up pop up to save the file instead it is showing
>> the content of xls file in xml format directly on the browser.
>>
>> Below mime type is set both at web.xml of webapplicatio end and as
>> well as Tomcat9038/conf/web.xml
>>
>> <mime-mapping>
>>      <extension>xls</extension>
>>      <mime-type>application/vnd.ms-excel</mime-type>
>>      </mime-mapping>
>>
>> Could you please help in resolving the issue ASAP
>>
>>
>> Thanks
>> Swathi
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat server not considering Mime Type - Request urgent help!!

Posted by "Jonnalagadda, Swathi (External)" <Sw...@xerox.com>.
Thank you for the email

We could see that when we try to open the xls file separately the browser shows dialogue box to save it so it is nothing to do with browser settings

Could you please advise if I am missing out any setting here.

Thanks
Swathi
-----Original Message-----
From: Mounika Reddy [mailto:spidermain12@gmail.com] 
Sent: Wednesday, January 13, 2021 3:48 AM
To: Tomcat Users List
Cc: Mark Thomas
Subject: Re: Tomcat server not considering Mime Type - Request urgent help!!

CAUTION:   This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Pls check http response headers for the request to confirm if it's returning proper headers.

Once they are in place then it may be to do with browser settings not processing headers.



On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) < Swathi.Jonnalagadda@xerox.com> wrote:

> Hi Team
>
> We have an application deployed in tomcat9.0.38 server which generates 
> an xls file dynamically and saves at server end. When we try to access 
> the file using application frontend, it is neither showing up in excel 
> format nor showing up pop up to save the file instead it is showing 
> the content of xls file in xml format directly on the browser.
>
> Below mime type is set both at web.xml of webapplicatio end and as 
> well as Tomcat9038/conf/web.xml
>
> <mime-mapping>
>     <extension>xls</extension>
>     <mime-type>application/vnd.ms-excel</mime-type>
>     </mime-mapping>
>
> Could you please help in resolving the issue ASAP
>
>
> Thanks
> Swathi
>

Re: Tomcat server not considering Mime Type - Request urgent help!!

Posted by Mounika Reddy <sp...@gmail.com>.
Pls check http response headers for the request to confirm if it's
returning proper headers.

Once they are in place then it may be to do with browser settings not
processing headers.



On Tue, Jan 12, 2021, 2:48 PM Jonnalagadda, Swathi (External) <
Swathi.Jonnalagadda@xerox.com> wrote:

> Hi Team
>
> We have an application deployed in tomcat9.0.38 server which generates an
> xls file dynamically and saves at server end. When we try to access the
> file using application frontend, it is neither showing up in excel format
> nor showing up pop up to save the file instead it is showing the content of
> xls file in xml format directly on the browser.
>
> Below mime type is set both at web.xml of webapplicatio end and as well as
> Tomcat9038/conf/web.xml
>
> <mime-mapping>
>     <extension>xls</extension>
>     <mime-type>application/vnd.ms-excel</mime-type>
>     </mime-mapping>
>
> Could you please help in resolving the issue ASAP
>
>
> Thanks
> Swathi
>