Java tutorial
package com.etcc.csc.presentation.action.monthlyStatement; import com.etcc.csc.common.DelegateEnum; import com.etcc.csc.common.DelegateFactory; import com.etcc.csc.dto.AccountLoginDTO; import com.etcc.csc.dto.LicensePlateDTO; import com.etcc.csc.presentation.datatype.PaymentContext; import com.etcc.csc.service.PaymentInterface; import com.etcc.csc.util.SessionUtil; import java.math.BigDecimal; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.DynaActionForm; public class ProcessMonthlyStatementAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaActionForm dynaForm = (DynaActionForm) form; String licensePlate = (String) dynaForm.get("licensePlate"); HttpSession session = request.getSession(); AccountLoginDTO accountLoginDTO = SessionUtil.getSessionAccountLogin(session); LicensePlateDTO[] licensePlates = accountLoginDTO.getLicensePlates(); if (licensePlates == null || licensePlates.length == 0) { PaymentInterface pi = (PaymentInterface) DelegateFactory.create(DelegateEnum.PAYMENT_DELEGATE); //Task 2128_1 implementation. To display link to access Monthly Statements List<LicensePlateDTO> licensePlateDTOList = pi.getAccountLicPlates(accountLoginDTO.getAcctId()); accountLoginDTO .setLicensePlates(licensePlateDTOList.toArray(new LicensePlateDTO[licensePlateDTOList.size()])); licensePlates = accountLoginDTO.getLicensePlates(); SessionUtil.setSessionAccountLogin(session, accountLoginDTO); } if (StringUtils.isEmpty(licensePlate) && !ArrayUtils.isEmpty(licensePlates)) { licensePlate = licensePlates[0].getDisplayLicPlateValue(); dynaForm.set("licensePlate", licensePlate); } if (StringUtils.isNotEmpty(licensePlate)) { String[] licensePlateArr = licensePlate.split("~"); accountLoginDTO.setLicPlate(licensePlateArr[0]); accountLoginDTO.setLicState(licensePlateArr[1]); accountLoginDTO.setViolatorId(Long.valueOf(licensePlateArr[2])); SessionUtil.setSessionAccountLogin(session, accountLoginDTO); return mapping.findForward("process.monthlyStatement"); } return mapping.findForward("success"); } }