Weblogic: Binary file is rendered instead of downloading - weblogic

I am having a html file which has anchor tag linking to the binary file in same ear. Problem is when I am clicking on anchor tag, the binary file is rendered instead of prompting for download or download. Doesnt have problem when using apache. Tried specifying mimetype in anchor tag by using attribute content-type="application/octet-stream" but didnt help.
Environment used is weblogic linux.

I think we need to configure mime-type at the server level rather than # anchor tags as server first would recognize the mime-type extension to service the download
Ref
https://blogs.oracle.com/brunoborges/entry/ohs_and_apk_files

Related

Scroll SVN-stored text file served by Apache

I have a 1.7.9 SVN server exposed via Apache. It uses apache2-svn which allows to specify revision number as a part of the URL like this (for r65):
https://SERVER:PORT/REPO/FILE?p=65
I'd like to add a parameter to a query string that allows scrolling the file or even better - highlighting a range in the file. So users can send links pointing to "revision 65, lines 110-125".
Any ideas? The SVN stores only regular text files. Do browsers even support scrolling an arbitrary text file? Or would I need to transform the file into a HTML document? Any ready to use solution?
Cheers,
Pawel
Built-in Apache's SVN repository browsing feature is very simple and minimalistic. It does not allow you to specify the particular string to navigate to. The available URL syntax allows
viewing / downloading a particular file:
https://svn.domain.com/svn/MyProject/trunk/README.txt
viewing / downloading a particular file in revision 321:
https://svn.domain.com/svn/MyProject/trunk/README.txt?r=321
viewing / downloading a particular file, which is not available in the youngest revision, by specifying peg revision:
https://svn.domain.com/svn/MyProject/trunk/FILE_ID.DIZ?p=123
combining both of the above methods you can tune the view.
If you want more browsing features, install 3-rd party repository browsing UI. Take a closer look at ViewVC, WebSVN and Sventon.

Server side: detecting if a user is downloading (save as...) or visualizing a file in the browser

I'm writing an apache2 module
by default and when viewed in a web browser, the module would only print the first lines of a large file and convert them to HTML.
if the user choose to 'download as...', the whole raw file would be downloaded.
Is it possible to detect this choice on the server side ? (for example is there a specific http header set ?).
note: I would like to avoid any parameter in the GET url (e.g: "http://example.org/file?mode=raw" )
Pierre
added my own answer to close the question: as said #alexeyten there is no difference. I ended by a javascript code the alter the index.html file generated by apache.

Can't display a pdf file in my jsf2 application

I try to display a pdf file on my jsf2 application and the problem is in the path file.
My pdf file is inside a folder named FichesPratiques which is inside another folder named resources (folder resources is inside WebContent) and I use this to display it :
<p:media value="/resources/FichesPratiques/file.pdf" width="100%" height="300px">
but anything is displayed.
and more strange, when I use link below to download it, it doesn't work.
<h:outputLink value="/resources/FichesPratiques/file.pdf">click</h:outputLink> to download pdf instead.
Can someone help me ?
Look closer at the URL generated in the HTML output of those components (rightclick, View Source in webbrowser). In contrary to among others the <h:graphicImage value>, the <p:media value> and <h:outputLink value> do not prepend the web application context path in the URL. The leading / in the URL makes it relative to the domain root of the request URL (the one as you see in browser's address bar).
Imagine that the JSF page is been opened by
http://localhost:8080/somecontext/page.xhtml
Then those value="/resources/FichesPratiques/file.pdf" paths would expect the resource to be present in
http://localhost:8080/resources/FichesPratiques/file.pdf
However, you actually have it in
http://localhost:8080/somecontext/resources/FichesPratiques/file.pdf
You should either be using a valid URL relative to the current request URL,
<p:media value="resources/FichesPratiques/file.pdf" ... />
or explicitly specify the context path in the URL,
<p:media value="#{request.contextPath}/resources/FichesPratiques/file.pdf" ... />

Pre-compress static files in IIS 6

I am implementing Gzip compression for CSS and JS files on my site and just need to double check something.
Is the file compressed on every request? or is it collected and sent from the Temporary folder (if the file exists)? I just want to be sure that my files are not compressed on every request.
Also, is this a default behaviour or do I need some extra configurtion?
And last, do I need to worry or configure something when using hash tags in the path (to inform the browser that the file has changed) and static file compression? or it should work with no problem.
Edit: I am just using static compression
Many thanks
In order to get the most out of IIS compression you will need to add a few extra bits into the metabase file.
Backup your meta base file.
Enable live edit to the meta base file in IIS (or you need to restart IIS when your done.)
find the IIsCompressionScheme and make the following edits to the meta base file
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="htm
html
css
js
txt
xml"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
aspx
axd
ashx
asbx
asmx
swf
asmx
exe"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="htm
html
js
css
txt
xml"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
aspx
axd
ashx
asbx
asmx
swf
asmx
exe"
>
</IIsCompressionScheme>
Once done test a page from your site using a FF plug in like YSlow or Firebug, with Firebug you can inspect each element in the Net tab and check if the right compression is being applied to the right file types.
There is a great article with examples here http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html
IIS 6 supports both dynamic and static compression.
Have look at the relevant documentation and a decent blog entry on the subject.
"The newly compressed file is then stored in the compression directory, and subsequent requests for that file are serviced directly from the compression directory. In other words, an uncompressed version of the file is returned to the client unless a compressed version of the file already exists in the compression directory."*
Taken from this article.

Link to file outside context root of weblogic

If I want to display an image in my webpage and its src is a file outside context root.
At the IDE, the image is shown to be loaded.
But when I test the web page, nothing displayed.
How can I config weblogic server to allow the image to be displayed. If not is there anyway to run around this problem.
Thanks a lot.
You can use the Virtual Directory Mapping feature (that you declare in the weblogic.xml):
Using the virtual directory mapping
feature, you can create one directory
to serve static files such as images
for multiple Web Applications. For
example, you would create a mapping
similar to the folowing:
<virtual-directory-mapping>
<local-path>c:/usr/gifs</local-path>
<url-pattern>/images/*</url-pattern>
</virtual-directory-mapping>
A request to
http://localhost:7001/mywebapp/images/test.gif
will cause your WebLogic Server
implementation to look for the
requested image at:
c:/usr/gifs/images/*.
This directory must be located in the
relative uri, such as
"/images/test.gif".