⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 homepageaction.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
字号:
/*
 * @author                        : Sujatha
 * @Version                       : 1.0
 *
 * Development Environment        : Oracle9i JDeveloper
 * Name of the File               : HomePageAction.java
 * Creation/Modification History  :
 *
 * Sujatha   16-Jan-2003      Created
 *
 */
package oracle.otnsamples.vsm.actions.owner;


// IO and servlet API
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import oracle.otnsamples.util.ServiceLocator;
import oracle.otnsamples.vsm.services.ShopException;
import oracle.otnsamples.vsm.services.ShopOwner;
import oracle.otnsamples.vsm.services.ShopOwnerHome;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


/**
 * This action class is used to diplay the home page for the shop owner.
 * 
 * @author Sujatha
 * @version 1.0
 */
public class HomePageAction extends Action {
  /**
   * This is the action called from the Struts framework to get the shop ID of
   * shop owner
   *
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   */
  public ActionForward execute(
                               ActionMapping mapping, ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response)
                               throws IOException, ServletException {

    ShopOwnerHome shopHome = null;
    ShopOwner shop         = null;
    ActionForward forward  = mapping.findForward("display");

    try {
      shopHome =
        (ShopOwnerHome) ServiceLocator.getLocator().getService("ShopOwner");
      shop = shopHome.create();

      String userName = (String) request.getSession().getAttribute("userName");

      if(userName != null) {

        String shopID = shop.getShopForUser(userName);
        request.getSession().setAttribute("shopID", shopID);
      }
    } catch(ShopException ex) {
      servlet.log("OwnerHomePageError", ex);                            
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } catch(Exception ex) {
      servlet.log("OwnerHomePageError", ex);                            
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } finally {

      try {

        if(shop != null) {
          shop.remove();
        }
      } catch(Exception ex) {
      }
    }
    return forward;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -