What is the difference between callling a RequestDispatcher
using ServletRequest and ServletContext?

Answers were Sorted based on User's Feedback



What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext..

Answer / mahesh

We can give relative URL when we use ServletRequest and not
while using ServletContext.

Is This Answer Correct ?    7 Yes 0 No

What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext..

Answer / prachetash

RequestDispatcher rd = request.getRequestDispatcher("result.jsp")

This is relative path, becoz there is no "/" slash.Container looks in same logical path.

RequestDispatcher rd = getServletContext.getRequestDispatcher("/result.jsp")

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Servlets Interview Questions

How httpservlet is different from the genericservlet?

0 Answers  


Can we fetch the attributes related to a servlet on a different servlet?

0 Answers  


Can we get PrintWriter and ServletOutputStream both in a servlet?

0 Answers  


How does java thread pool work?

0 Answers  


Is servlet a server side scripting language?

0 Answers  


how can you give alias to servlets?

1 Answers  


Which exception is thrown if the servlet is not initialized properly?

0 Answers  


How can I share objects across different sessions?

2 Answers   Accenture,


Why is init() method is used in servlets?

0 Answers  


List some life cycle methods of a servlet.

0 Answers  


when the jsp page is translated to servlet?

5 Answers   HCL,


What is cgi?

0 Answers  


Categories