• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2eeCertificate Practice exam question

 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Q : How do you add the content-type header "video/mpeg" to the response ?

options : 1. response.setHeader("content-type","video/mpeg");
2. response.setContentType("video/mpeg");
3. response.addContentType("video/mpeg");
and other 2 options.

we can select only one answer. The answer given is 2. why the option 1 is not correct? any clue ?

Thanks
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Narendra,

I tried setting content-type by

response.setHeader("content-type","video/mpeg");

in my JSP and it works fine. So, there might be a mistake...

I have one more thought...
The question is
How do you "add" the content-type header "video/mpeg" to the response ?

if you consider "add", in that case even option 1 is not correct, because it is not adding the video/mpeg to content-type, it is resetting content-type to video-mpeg. So basically, both the answers are incorrect... and if there is an option of

response.addHeader("content-type","video/mpeg");

that would be correct...


Regards,

Sushma
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

It's too late. But I feel to clear my doughts.

Your quote

if you consider "add", in that case even option 1 is not correct, because it is not adding the video/mpeg to content-type, it is resetting content-type to video-mpeg. So basically, both the answers are incorrect... and if there is an option of

response.addHeader("content-type","video/mpeg");



I had not tested. But setting multiple content-type headers is not useful in JSP. Therefore we can use either setHeader or setContentType.

Thanks
 
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Q : How do you add the content-type header "video/mpeg" to the response ?

options : 1. response.setHeader("content-type","video/mpeg");
2. response.setContentType("video/mpeg");
3. response.addContentType("video/mpeg");
and other 2 options.



Both 1 and 2 are correct. It must be a mistake
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic