Author
Why an inner class?
Carol Murphy
village idiot
Bartender
Joined: Mar 15, 2001
Posts: 1172
This is one of the versions of BeeServlet from the CattleDrive assignments on Servlets . I'm planning on using this as the model for my code, but I'm wondering why Default is coded as an inner class. (Though I'm copying, I figure I should still know why I'm doing what I'm doing!) package com.javaranch.drive ; import com.javaranch.common.* ; public class BeeServlet extends ActionServlet { private class Default implements ActionHandler { public void doAction( ServletData servletData ) { servletData.setAttribute( "text" , "MVC2-buzz-buzz ..." ); forward( "/bee.jsp" , servletData ); } } public void init() { addActionHandler( "default" , new Default()); } } If Default was moved outside of BeeServlet, would it make any difference?
Choon-Chern Lim
Ranch Hand
Joined: Aug 29, 2005
Posts: 74
posted Sep 02, 2005 18:03:00
0
http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html
Carol Murphy
village idiot
Bartender
Joined: Mar 15, 2001
Posts: 1172
Thanks Choon-Chern. That's a useful link!
subject: Why an inner class?