Hello all!
In the famous Java Pet Store 1.1, new user can register to become a member.
After he registers, he automatically logged in to the application.
Here is the code:
+++++++ START CODE ++++++++
package com.sun.j2ee.blueprints.petstore.control.web;
public class RequestProcessor {
// variable declarations ...
public void init(ServletContext context) {
// init method implementation ...
}
/**
* This method is the core of the RequestProcessor. It receives all
requests
* and generates the necessary events.
*/
public void processRequest(HttpServletRequest request) throws
EStoreEventException {
EStoreEvent event = null;
ModelManager mm =
(ModelManager)request.getSession().getAttribute(WebKeys.ModelManagerKey);
ShoppingClientControllerWebImpl scc =
(ShoppingClientControllerWebImpl)request.getSession().getAttribute(WebKeys.W
ebControllerKey);
if (scc == null) {
scc = new ShoppingClientControllerWebImpl(request.getSession());
mm.setSCC(scc);
request.getSession().setAttribute(WebKeys.WebControllerKey,
scc);
}
try {
checkForWebServerLogin(request, mm, scc);
event = eventTranslator.processRequest(request);
if (event != null) {
Collection updatedModelList = scc.handleEvent(event);
/* This portion of code automatically logs a user into the
* web server when a new account is created. The user will
* not see the form based login page.
*/
if ((event instanceof AccountEvent) &&
((AccountEvent)event).getActionType() == AccountEvent.CREATE_ACCOUNT) {
if (securityAdapter != null) {
securityAdapter.loginUser(((AccountEvent)event).getUserId(),
((AccountEvent)event).getPassword(), request.getSession());
}
mm.notifyListeners(updatedModelList);
checkForWebServerLogin(request, mm, scc);
// invalidate current session and replace it with a new
session
}
mm.notifyListeners(updatedModelList);
if (event instanceof LogoutEvent) {
// do something ...
}
}
} catch (LoginFailedException lfe) {}
}
private void checkForWebServerLogin(HttpServletRequest request,
ModelManager mm, ShoppingClientControllerWebImpl scc){
// do something...
}
}
++++++ END CODE ++++++
can we do it in JRun 3.0?
Budi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists