Mobile app version of vmapp.org
Login or Join
Sue5673885

: How to force a web browser to interpret other file extension (but contains plain text) as a text file? I'm currently engaged with a web based application that needs to show text files via

@Sue5673885

Posted in: #Apache #InternetExplorer8 #WebDevelopment

I'm currently engaged with a web based application that needs to show text files via directory listing in the web server (Tomcat). The text file has an extension of .inp and .trg, it seems that IE8 is not wrapping the text properly and ignores the white spaces and line breaks of the file. When I create a sample plain text in my directory with the extension of .txt, IE8 interprets it properly. Can you give me a solution for IE8 to interpret word-wrapping with file extension ( .inp, .trg ) rather than .txt?

The previous application is deployed in Apache, and IE8 interprets the wrapping properly. Apparently when it is deployed in tomcat the wrapping is gone. By the way I'm using Jython.

Will it be on the server side (Tomcat)? or in the client side (web browser)?

Thanks!

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Sue5673885

2 Comments

Sorted by latest first Latest Oldest Best

 

@Sent6035632

In Apache2, and it should be enough since Tomcat should just pass the data along, you can add a MIME type based on file extensions. This is done with the AddType command:

AddType text/plain .inp
AddType text/plain .trg


Note that if you dynamically generate these files, then setting the Content-Type: ... header is your solution.

10% popularity Vote Up Vote Down


 

@Hamaas447

For Tomcat, add the MIME types in the conf/web.xml file, as given below

<mime-mapping>
<extension>inp</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>


for each extension

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme