Home > Archive > Java Help > February 2006 > setContentType() -- args that can be passed..
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
setContentType() -- args that can be passed..
|
|
| Frances 2006-02-17, 7:00 pm |
| please, what are all possible arguments you can pass to setContentType()
method? (not listed in Servlet API..) am esp interested in mime types
for media (video, audio) but out of curiosity would like to see a list
of all possible arguments that can be passed to this method.. thanks..
Frances
| |
| Frances 2006-02-17, 7:00 pm |
| Frances wrote:
> please, what are all possible arguments you can pass to setContentType()
> method? (not listed in Servlet API..) am esp interested in mime types
> for media (video, audio) but out of curiosity would like to see a list
> of all possible arguments that can be passed to this method.. thanks..
>
> Frances
ok, found a list of all MIME types here...
http://www.webmaster-toolkit.com/mime-types.shtml
however: found no type for .wmv (windows media video) why is this..
thank you..
| |
| Oliver Wong 2006-02-17, 7:00 pm |
|
"Frances" <fdr58@yahoo.com> wrote in message news:43f63353_1@x-privat.org...
> Frances wrote:
>
> ok, found a list of all MIME types here...
> http://www.webmaster-toolkit.com/mime-types.shtml
>
> however: found no type for .wmv (windows media video) why is this.. thank
> you..
The string you used gets passed to the browser which interprets it. As
long as you and the browser agree on the conventions, you can pass anything
string you want
For most purposes, I think most browsers just ignore this information
anyway, as they only do 1 of two things with content they receive. Display
it (if it's HTML, TXT, XML, GIF, JPG, SWF, PNG or PDF), or download it
(everything else).
- Oliver
| |
| Frances 2006-02-17, 7:00 pm |
| Oliver Wong wrote:
>
> "Frances" <fdr58@yahoo.com> wrote in message
> news:43f63353_1@x-privat.org...
>
>
>
> The string you used gets passed to the browser which interprets it.
> As long as you and the browser agree on the conventions, you can pass
> anything string you want
>
> For most purposes, I think most browsers just ignore this information
> anyway, as they only do 1 of two things with content they receive.
> Display it (if it's HTML, TXT, XML, GIF, JPG, SWF, PNG or PDF), or
> download it (everything else).
>
> - Oliver
thank you Oliver.. the reason I asked about .wmv is that in a servlet I
did (having put relevant media files in root of webapp):
String testRM = context.getMimeType("/Stream/video.rm");
out.println(testRM);
// prints: application/vnd.rn-realmedia
String testWM = context.getMimeType("/Stream/video.wmv");
out.println(testWM);
// prints: NULL // why get NULL here....
thank you.. Frances
| |
|
|
| Frances 2006-02-18, 6:58 pm |
| Roedy Green wrote:
> On 17 Feb 2006 21:34:27 +0100, Frances <fdr58@yahoo.com> wrote, quoted
> or indirectly quoted someone who said :
>
>
>
>
> video/x-ms-wmv
>
> See http://mindprod.com/jgloss/mime.html
thank you Roedy.. still can't find this type (.wmv) in above-mentioned
mime-types page, or other ones, like
http://www.ltsw.se/knbase/internet/video.htp, or
or http://www.w3schools.com/media/media_mimeref.asp
and get NULL when I do:
String testWM = context.getMimeType("/stream/video.wmv");
out.println(testWM); // prints NULL.. why is this...
// (video file is in path passed to getMimeType() method..)
thank you..
Frances
| |
| Roedy Green 2006-02-18, 6:58 pm |
| On 18 Feb 2006 23:19:23 +0100, Frances <fdr58@yahoo.com> wrote, quoted
or indirectly quoted someone who said :
> String testWM = context.getMimeType("/stream/video.wmv");
MIME types are a ruddy mess. People just make them up, make up several
for the same thing. They reuse extensions for sever different mime
types and vice versa. There is no master list.
So people like me gradually compile lists. So did Sun. It is
necessarily incomplete. That association is simply not in their table.
I suspect though you don't really need it. You likely can specify the
extension and mime yourself explicitly to allow for this situation.
Not the mime type is NOT stream/video.wmv but video/x-ms-wmv
You are just asking sun help looking up video/x-ms-wmv.
Also see http://mindprod.com/jgloss/sniffer.html
so you can snoop on successful browsers and servers dealing with this
sort of data to see what are doing with their headers.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
| |
| Juha Laiho 2006-02-18, 6:58 pm |
| Frances <fdr58@yahoo.com> said:
>Oliver Wong wrote:
Yes, MS browsers have been buggy in the sense that they ignore mime-type
and then try to guess the type based on content. I think this has resulted
in more than one security incidents with MSIE.
Rather, mime type should be honored, and content discarded if it doesn't
match with the declared type (or, the user may be given the option to
save the content in a file).
[color=darkred]
>thank you Oliver.. the reason I asked about .wmv is that in a servlet I
>did (having put relevant media files in root of webapp):
>
> String testRM = context.getMimeType("/Stream/video.rm");
> out.println(testRM);
> // prints: application/vnd.rn-realmedia
>
> String testWM = context.getMimeType("/Stream/video.wmv");
> out.println(testWM);
> // prints: NULL // why get NULL here....
The servlet API javadocs tell:
: getMimeType
:
: public java.lang.String getMimeType(java.lang.String file)
:
: Returns the MIME type of the specified file, or null if the MIME type
: is not known. The MIME type is determined by the configuration of the
: servlet container, and may be specified in a web application deployment
: descriptor. Common MIME types are "text/html" and "image/gif".
:
: Parameters:
: file - a String specifying the name of a file
: Returns:
: a String specifying the file's MIME type
Based on this I guess that there's no relation from .wmv extension to
any mime type in your servlet engine (it was Tomcat, wasn't it?)
configuration. You can correct this by declaring the mime type to
file extension relation in your web.xml; see the "Servlet Specification"
for mime-mapping element.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
| |
| Frances 2006-02-19, 7:00 pm |
| Juha Laiho wrote:
> Frances <fdr58@yahoo.com> said:
>
>
>
> Yes, MS browsers have been buggy in the sense that they ignore mime-type
> and then try to guess the type based on content. I think this has resulted
> in more than one security incidents with MSIE.
>
> Rather, mime type should be honored, and content discarded if it doesn't
> match with the declared type (or, the user may be given the option to
> save the content in a file).
>
>
>
>
> The servlet API javadocs tell:
> : getMimeType
> :
> : public java.lang.String getMimeType(java.lang.String file)
> :
> : Returns the MIME type of the specified file, or null if the MIME type
> : is not known. The MIME type is determined by the configuration of the
> : servlet container, and may be specified in a web application deployment
> : descriptor. Common MIME types are "text/html" and "image/gif".
> :
> : Parameters:
> : file - a String specifying the name of a file
> : Returns:
> : a String specifying the file's MIME type
>
> Based on this I guess that there's no relation from .wmv extension to
> any mime type in your servlet engine (it was Tomcat, wasn't it?)
> configuration. You can correct this by declaring the mime type to
> file extension relation in your web.xml; see the "Servlet Specification"
> for mime-mapping element.
thank you Juha!! ok, so no matter what MIME types exist or don't exist
out there, for Tomcat they have to be specified in web.xml (the one
here, C:\tomcat\conf.. and as matter of fact, there are a LOT of
MIME-types specified there..) this worked... thank you... :)
are you enjoying Winter Olympics...
Frances
| |
| Juha Laiho 2006-02-20, 7:00 pm |
| Frances <fdr58@yahoo.com> said:
>Juha Laiho wrote:
>
>thank you Juha!! ok, so no matter what MIME types exist or don't exist
>out there, for Tomcat they have to be specified in web.xml (the one
>here, C:\tomcat\conf.. and as matter of fact, there are a LOT of
>MIME-types specified there..) this worked... thank you... :)
Mmm, yes, you can do it that way - but then you'll have to change
every server on which you wish to run your application (and remember
to update the settings after you upgrade Tomcat).
You can also place the mappings to the web.xml within your application
(so, <contextRoot>/WEB-INF/web.xml), from where they will be added to
the mappings provided by the container (just for that single
application).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
| |
| Frances 2006-02-21, 7:03 pm |
| Juha Laiho wrote:
> Frances <fdr58@yahoo.com> said:
>
>
>
> Mmm, yes, you can do it that way - but then you'll have to change
> every server on which you wish to run your application (and remember
> to update the settings after you upgrade Tomcat).
>
> You can also place the mappings to the web.xml within your application
> (so, <contextRoot>/WEB-INF/web.xml), from where they will be added to
> the mappings provided by the container (just for that single
> application).
thanks, Juha.. I did put it in web.xml for webapp (since at my website
don't think I can chg general web.xml..) however, get SERVERE errors now
when start up Tomcat.. I put MIME-type specs inside <web-app> tags..
Tomcat now says web.xml is missing ending </web-app> tag, but it's
there.. i.e., now have:
<web-app>
<servlet>
...
</servlet>
<servlet-mapping>
...
</servlet-mapping>
</mime-mapping>
...
</mime-mapping>
</web-app>
this should be ok, right? thanks again.. Frances
| |
| Oliver Wong 2006-02-21, 7:03 pm |
|
"Frances" <fdr58@yahoo.com> wrote in message
news:43fb5d44$1_1@x-privat.org...
> thanks, Juha.. I did put it in web.xml for webapp (since at my website
> don't think I can chg general web.xml..) however, get SERVERE errors now
> when start up Tomcat.. I put MIME-type specs inside <web-app> tags..
> Tomcat now says web.xml is missing ending </web-app> tag, but it's there..
> i.e., now have:
>
> <web-app>
>
> <servlet>
> ...
> </servlet>
>
> <servlet-mapping>
> ...
> </servlet-mapping>
>
> </mime-mapping>
> ...
> </mime-mapping>
>
> </web-app>
>
>
> this should be ok, right? thanks again.. Frances
You're closing <mime-mapping> twice, instead of opening it once and
closing it once.
- Oliver
| |
| Frances 2006-02-21, 7:03 pm |
| Oliver Wong wrote:
>
> "Frances" <fdr58@yahoo.com> wrote in message
> news:43fb5d44$1_1@x-privat.org...
>
>
>
> You're closing <mime-mapping> twice, instead of opening it once and
> closing it once.
>
> - Oliver
yep, I'm a jerk... sorry.... many thanks...
|
|
|
|
|