-
A simple question on setContentType
Hi All,I'm a newbie to Java servlet,just wonder a very simple question:
For the method
response.setContentType("text/html"),what's the
meaning of the left and right stuff of "/", I mean,can
I switch them? And also("image/gif").
-
Re: A simple question on setContentType
What you see as the parameter of setContentType() is an Internet constant
known as a "MIME type". They describe the document that follows. Often
servlets are sending an HTML document, so the content type for that is
"text/html". If you're sending a GIF file, then you use "image/gif", and if
you're sending an Adobe PDF document you use "application/pdf". There's a
big list of these, partially set by a standards committee, which you can
find somewhere on the Internet (but I forget where).
Can you switch the two halves? Sure, and you can try using the
"setTypeContent()" method too, but you won't get a useful result.
PC2
H. Ma <mahuiyuan@yahoo.com> wrote in message news:3a96aae3@news.devx.com...
>
> Hi All,I'm a newbie to Java servlet,just wonder a very simple question:
> For the method
> response.setContentType("text/html"),what's the
> meaning of the left and right stuff of "/", I mean,can
> I switch them? And also("image/gif").
>
>
-
Re: A simple question on setContentType
Thanks a lot for your answer. So,you mean, the right one to the '/' is what
the servlet sends, and what about the left one? why is it 'text' to 'html'?
Why it should be 'image' upon 'gif'? Thanks again.
-
Re: A simple question on setContentType
No, you have to put both "parts" in the correct order. These codes were
designed by a standards organization so "WHY" is not a relevant question.
That's the way it is.
PC2
H Ma <mahuiyuan@yahoo.com> wrote in message news:3a99d2d4$1@news.devx.com...
>
> Thanks a lot for your answer. So,you mean, the right one to the '/' is
what
> the servlet sends, and what about the left one? why is it 'text' to
'html'?
> Why it should be 'image' upon 'gif'? Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|