commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
Subject Re: [fileupload] jsp mime type
Date Wed, 22 Dec 2004 04:56:57 GMT
On Tue, 21 Dec 2004 19:58:08 -0600, Matt Bathje <> wrote:
> Hey all -
> I posted this to the struts list a while back, but got no responses and
> it is probably more appropriate here.
> I am working with the commons file uploader in struts to upload a JSP
> file to my website. Being a security conscious developer, I am limiting
> the available upload file types to text/plain and text/html hoping that
> the JSP file would be sent as one of these types.

Perhaps I'm misunderstanding what you're trying to do, but the MIME
type that the browser submits for an upload would have to be
configured on the browser, not the server.

> Instead, it is sent as application/octet-stream - which is the same type
> used for executables and binary type files - seems kind of weird to me.

This is because the browser doesn't understand what the .jsp extension
means, so it is defaulting to application/octet-stream in order to
treat the file as nothing more than a byte stream.

> Does anybody know if there is a way to "force" jsp files to be of a
> text/plain (or some other text type) instead of
> application/octet-stream? I tried adding the following to my web.xml
> file (Tomcat 5.0.x):

I don't know if there's a way to configure the browser to understand
what the .jsp extension means from the perspective of file uploading.
Even if there is, each user would have to individually configure their
browser that way.

> <mime-mapping>
> <extension>jsp</extension>
> <mime-type>text/plain</mime-type>
> </mime-mapping>
> But it didn't seem to make a difference.

No, it wouldn't. These settings are used for downloading, rather than uploading.

Martin Cooper

> Thanks,
> Matt
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message