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

sebRedirect() can ask for the resource outside of current webapp??

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet may receive a request, which the servlet cannot handle. In such cases, you want to redirect the request to another resource which may or may not be a part of the same web application. Which of the following options can be used to achieve this objective?


1.
RequestDispatcher rd = this.getServletContext().getRequestDispatcher("some url");
rd.forward(request, response);

2.
RequestDispatcher rd = request.getRequestDispatcher("some url");
rd.forward(request, response);

3. response.sendRedirect("some url");

4. request.sendRedirect("some url");

option 3 is the right answer. Is responce.sendredirect can specify a url as its parameter to the recource which is not part of the current web application?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's quite easy to test, isn't it?
 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes It can send to any url with the help of your browser.

When browser take the URL it automatically send you to a new URL...SO your client do the request...

However with requestDispatcher your container handles in application inside redirection..

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anut
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic