• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

File download - Different behaviour of Windows & Linux server

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to show a PDF from a NAS server to the end user on clicking a link in my web app. The first part is to write it to a temporary location in Linux, then the other part is to provide a handle to the file(filename) to a servlet which streams the data.

This implementation works fine in Windows , where it pops up the file "Open /Save" dialog, but fails to give any response in Linux and I get a 404 page.

Any tips or ideas will be highly appreciated.

P.S: I am closing the file output streams as soon as I am done writing into the file. I have also verified that the files are actually created in Linux folder.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Geeks , still no reply ??
 
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But 404 means "Not Found". That means it's nothing to do with PDF, it's just that your Linux server is configured differently and fails to serve the URL with which you request the PDF. I expect that is happening here:

the other part is to provide a handle to the file(filename) to a servlet which streams the data


so it would be the URL which requests that servlet.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your efforts Paul Clapham.

I am actually not getting a FileNotFoundException in the server logs, but its just that the page is not getting loaded.
I verified the path of the file location by printing them in logs. This is what makes it confusing :(


 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, still I have not found the solution for this issue.

The following is the representation of LOC that I am using in the web component ( JSF bean). The below code works fine in Windows and there are no syntax errors.




Please provide your valuable inputs. I am at this issue for a long time. I even tried SOP statements to print the byte array in JSF Bean within the getData().
 
Paul Clapham
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:I even tried SOP statements to print the byte array in JSF Bean within the getData().



And you didn't see any output from them? Then that means the code you posted isn't being called, and isn't part of the problem. Instead it's something in your configuration which is sending the 404 error instead of calling that code.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could see that the SOP prints the byte array , but somehow it is being prevented from redirecting it to the "File Open/save" dialog as it happens in Windows.

In Mozilla Firefox, nothing happens on the screen and I stay on the same page.
 
Paul Clapham
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then it's still something to do with the environment you're running that code in, and nothing in particular to do with I/O or streams in general.

Is that environment something we have a forum for here? It might be more practical if we moved the question to that forum, if that's the case.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running it on JBoss 5 server on Linux machine.

I have also verified that the service end point configs have been set to support MTOM messages.
 
Paul Clapham
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, reading more carefully, I see you mentioned JSF. Could be something to do with JSF, something to do with JBoss. Pity we can't put the question into both forums at once, but let's try JSF first.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul. I hope to find some solution to this issue.
 
Saloon Keeper
Posts: 24499
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF should not be used for raw output. In JSF, the response stream is built from a tree-structured View definition where the specifications of the various page elements using a plug-in renderer component attuned to the destination media (usually HTTP). So if you attempt to grab the HttpOutputStream and jam stuff in it directly, your results are unpredictable whether the server's JBoss, Tomcat or WebLogic, and irrespective of the underlying operating system.

You can construct PDFs in a JSF application, but the actual PDF creation and output needs to be done by a non-JSF servlet or JSP. JSF is not one of those iron frameworks where every URL has to be routed through JSF.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:JSF should not be used for raw output. In JSF, the response stream is built from a tree-structured View definition where the specifications of the various page elements using a plug-in renderer component attuned to the destination media (usually HTTP). So if you attempt to grab the HttpOutputStream and jam stuff in it directly, your results are unpredictable whether the server's JBoss, Tomcat or WebLogic, and irrespective of the underlying operating system.

You can construct PDFs in a JSF application, but the actual PDF creation and output needs to be done by a non-JSF servlet or JSP. JSF is not one of those iron frameworks where every URL has to be routed through JSF.



Thanks for your suggestion Tim. But that didnt solve the issue

I tweaked the response header content type to binary instead of chunked and it solved the issue.
Not sure why it failed earlier because chunked should be used when the response content is supposed to be streamed in a buffered fashion.

I am posting my resolution here so that it will be useful for people who are facing similar issues. If anybody has a better solution please reply back
reply
    Bookmark Topic Watch Topic
  • New Topic