This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Cattle Drive and the fly likes Question about MVC2 BeeServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Question about MVC2 BeeServlet" Watch "Question about MVC2 BeeServlet" New topic

Question about MVC2 BeeServlet

juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
In the 2nd example code of BeeServlet we have in method init():

I do not quite understand what the first parameter ("default") is doing exactly.
In the API I read:
actionKey - The text that will be sent in the servlet parameter to kick off this action.

I think that init() starts class Default which then runs it's doAction() method. But what could class Default then do with param "default"?
Or would servletData be able to do something with it? And if yes, what??

Thank you for any enlightening hints!
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9055
The parameter is passed when the jsp calls the servlet. If no parameter is specified, "default" is called.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Richard J Barton

Joined: Feb 07, 2012
Posts: 6

I posted a similar question. what parameter is set in the jsp?
Greg Charles

Joined: Oct 01, 2001
Posts: 2865

The parameter is "action", so something like http://<myurl>/BeeServlet?action=default is what you need. There's nothing significant about "default" though. The framework just assumes the first action handler added is the default one, and uses that one if it can't find an "action" parameter in the request.
Richard J Barton

Joined: Feb 07, 2012
Posts: 6

thanks. I got it now.
In a link action=desiredAction
In a form a button with a name of action and a value of desiredAction.
Don't get me started about those stupid light bulbs.
subject: Question about MVC2 BeeServlet