• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

which class is implementing the RequestDispatcher interface

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are basic Java questions, not so much Servlet questions.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic