Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2eeCertificate Practice exam question

 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • 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
 
Sushma Sharma
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic