• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Browser not supplying cookie data in request

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

Our web application requires that a user logs in. This sets a cookie in all headers subsequently sent from the browser that contains the session id. This is how I determine if a user has logged in. If the header does not contain a session cookie then I redirect them to the login page.

Problem now is that I have a servlet that sends back a .xls file. The browser asks the user if they want to open or save the .xls file. If they choose 'open' the request does not have the cookie value set and they end up seeing my login page rendered as HTML in the excel file instead.

Has anyone had this problem before? What can I do to ensure that the browser sends the cookie in this request from the 'question dialog'. I did not expect this situation.

Thanks, Jared.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This sounds odd. The "File Open" dialog does not send a request. It is opened after the response has been received, and no further requests or responses between browser and server take place afterwards.

Apparently there's something inside of the XLS file that causes a request to be sent. That's out of the control of the browser, and consequently it's unlikely that any cookie would be sent along with it, ever.
 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Originally posted by Ulf Dittmer:
This sounds odd. The "File Open" dialog does not send a request. It is opened after the response has been received, and no further requests or responses between browser and server take place afterwards.



Exactly what I thought -- odd. However a second request to the same servlet is taking place after the first request arrives back though. I can see this when debugging in eclipse (and this request doesn't have any cookies set). I'll have a look at what the excel file has included in it. Maybe the problem is something obvious.

Thanks, Jared.

[ January 06, 2008: Message edited by: Jared Cope ]
[ January 06, 2008: Message edited by: Jared Cope ]
 
Jared Cope
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Alright finally figured this one out. Seems IE will pass the URL through to Excel and it is Excel that is making the second request. Firefox instead will pass the document through to excel for display instead. So IE would appear to do 2 requests, Firefox only one.

I have fixed this by modifying the header content type to the following instead:



This will make IE pass the downloaded file through to excel as I wanted. Hope this will help someone else.

Cheers, Jared.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic