A simple question on setContentType


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: A simple question on setContentType

  1. #1
    H. Ma Guest

    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").



  2. #2
    Paul Clapham Guest

    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").
    >
    >




  3. #3
    H Ma Guest

    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.

  4. #4
    Paul Clapham Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center