• Post Reply Bookmark Topic Watch Topic
  • New Topic

which class is implementing the RequestDispatcher interface  RSS feed

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
please tell me which class is implementing the RequestDispatcher interface
interface RequestDispatcher
{
----
}
class ?? implements RequestDispatcher
{
-------
}

2.Q) the service() method is compulsory required ServletException and IOException

ex: public void service(HttpServletRequest request,HttpServletResponse response) throws IOException

while writing the above service() method i am able to run the servlet program. I am getting the output with out writing the ServletException.

please clear me.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are basic Java questions, not so much Servlet questions.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.) The container you are using will pass you an instance of RequestDispatcher when you call either
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)
or
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)

You don't really need to concern yourself with the actual class. You nust need to know that it implements RequestDispatcher.
If you're curious about the class name and you want to see it, the following code, will print it to stdout.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2.) As David mentioned, exception handling and inheritance are not servlet specific questions. I'll let someone else answer that but....

It is worth mentioning that overriding the service method in a servlet is not a good practice. Rather, you should override the methods for the specific request type that you want your servlet to handle. This usually means doGet and/or doPost.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!