Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting to static resources

 
Kamal Tripathi
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: Javabeat Mock Exam

Which code has to be insert to redirect a resource by name 'resource.html' in the following code snippet?



a. res.sendTo("./resource.html")
b. request.sendTo("./resource.html")
c. res.sendRedirect("./resource.html")
d. request.getRequestDispatcher("./resource.html").forward(req, res);
e. res.forward("./resource.html")

Answer: C.

I went for C & D. Also let me know if we can mention URLs to resources in the UNIX way using . and .. as has been done in the example. I thought they should either begin with "/" or some valid folder/resource name.
 
nisha chidella
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question specifically says redirect, so only c is the right answer not d. remember, with redirect the response goes back to the client(browser) and a new request is made by the client to the redirected resourse, whereas in forward, the response doesn't go the client, it simply forwards the request to the another resourse.

may be ./ is used in UNIX for / in windows. need confirmation from some unix user.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice explanation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic