• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpServlet question

 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the following code can work:
public class sampleServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
req.getSession().setAttribute("userid", userid);
}
}
my question is that
since doXXX(HttpServletRequest req, HttpServletResponse res) throws ServletException in HttpServlet, why doesn't the doPost of sampleServlet need to catch ServletException or to throw it
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Timber,
This really has nothing to do with servlets, per se. When you extend a class and override a method, Java insists that the new method cannot be declared as throwing checked exceptions of classes other than those that were declared by the original method. However, It may throw exceptions derived from the base-class exceptions, some of the base-class exceptions, or none of them at all.
-BK
 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank Barry Kushnir
[ October 14, 2002: Message edited by: timber lee ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic