|
INTERVIEW QUESTIONS
J2EE
SERVLET
DETAILS
Question: What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest
Answer: You can get a RequestDispatcher object from either a request or the web context; however, the two methods have slightly different behavior. The method takes the path to the requested resource as an argument. A request can take a relative path (that is, one that does not begin with a /), but the web context requires an absolute path. If the resource is not available or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition
|
|
|
Category |
Servlet Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6818 users |
Added on |
7/17/2011 |
Views |
68873 |
Rate it! |
|
|
Question:
What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest
Answer:
You can get a RequestDispatcher object from either a request or the web context; however, the two methods have slightly different behavior. The method takes the path to the requested resource as an argument. A request can take a relative path (that is, one that does not begin with a /), but the web context requires an absolute path. If the resource is not available or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition Source: CoolInterview.com
servlet context need to give absolute path, where as request relative path is enough.... more over request is fulfil wen the service() methods comes to that line, but context fulfil wen server start execution Source: CoolInterview.com
Answered by: Gopi | Date: 4/17/2009
| Contact Gopi
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
Explain StringBuffers and StringTokenizers?
|
View Answer
|
|
What is differents between forword(),include() and sendRedirect()? In which circumtances all are used? Give Proper Examles
|
View Answer
|
|
What are the types of refrences available in java. How they work
|
View Answer
|
|
What is difference between cgi and servlet in interview point
|
View Answer
|
|
Can we override the service method? if we can do that then why do we override only doGET() and doPost() methods if the servlet is of protocol specific?
|
View Answer
|
|
What will happen when we call the destroy method in the init method? will the servlet exist?
|
View Answer
|
|
Suppose number of servlets/jsps from various web applications want to access shared data, what is the mechanism to achieve the same?
|
View Answer
|
|
How to integare struts and hibernate
|
View Answer
|
|
What is meant by preintialization?
|
View Answer
|
|
Suppose there are 15 links on the homepage of a site and each link creates a new request, how your servlet controller would handle it? (Assuming you are using MVC-2)
|
View Answer
|
|
How to Access Session Variables in Servlets & JSp
|
View Answer
|
|
When we have the servlets/struts what is the perpose of EJB
|
View Answer
|
|
Which method is more advantageous doGET() or doPOST()? in which situation does we use doGET() then?
|
View Answer
|
|
How you can activate or call one another servlet method?
|
View Answer
|
|
Can we write destroy() method in the init() method of a Servelt.
if we can, what will happen?
if we cant , why we cant?
|
View Answer
|
|
Why init is used and not constructor for servlets initialization?
|
View Answer
|
|
What is the difference between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?
|
View Answer
|
|
What is the difference between GenericServlet and HttpServlet?
|
View Answer
|
|
What are the differences between GET and POST service methods?
|
View Answer
|
|
What is the difference between ServletContext and ServletConfig?
|
View Answer
|