How many ways are available to ger RequestDispatcher object?

Answer Posted / seshendra

There are three ways to get RequestDispatcher object in the
servlet.

1. calling the getRequestDispatcher(String path) method on
ServletRequest.

RequestDispatcher rd=request.getRequestDispatcher(String path);


2. By getRequRequestDispatcher(String path) method on
ServletContext.

RequestDispatcher rd=context.getRequestDispatcher(String path);

3.by calling getNamedDispatcher(servlet logical name)on
ServletContext object


RequestDispatcher rd=context.getNamedDispatcher(servlet
logical name)

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the type of protocols used in httpservlet?

616


Why do we need servlet filter?

574


How can you use a servlet to generate a plain text instead of html?

596


How do you load an image in a Servlet?

662


How to get the IP address of client in servlet?

632






What is meant by cookies?

615


How servlets are deployed in java?

547


What is Servlets and explain the advantages of Servlet life cycle?

585


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

638


Can we use threads in Servlets?

656


What is servlet configuration?

532


What are the types of servlets? Explain

677


Once the destroy() method is called by the container, will the servlet be immediately destroyed? What happens to the tasks(threads) that the servlet might be executing at that time?

777


What is difference between cookies and httpsession?

548


Why is httpservlet declared abstract?

582