difference in ServletRequest.getRequestDispather() and ServletContext.getRequestDispatcher() in Servlet

Servletrequest.getRequestDispatcher(“url”) means the dispatch is relative to the current HTTP request.
Example code:

RequestDispatcher reqDispObj = request.getRequestDispatcher("/login.jsp");

getServletContext().getRequestDispatcher(“url”) means the dispatch is relative to the root of the ServletContext.
Example code:

RequestDispatcher reqDispObj = getServletContext().getRequestDispatcher("/testApp/login.jsp");
Advertisements

About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: