This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes J2eeCertificate Practice exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "J2eeCertificate Practice exam question" Watch "J2eeCertificate Practice exam question" New topic
Author

J2eeCertificate Practice exam question

Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
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

Joined: Dec 04, 2004
Posts: 950
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

Joined: Aug 24, 2004
Posts: 250
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


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: J2eeCertificate Practice exam question
 
Similar Threads
A Video Player
Problem of downloading and displaying a MOV file
MP3 on J2ME??
video/mpeg mapping
Doubt