/**
 * <p>Title: ShoppingCartAction Class>
 * <p>Description:	This class initializes the fields of ShoppingCart.jsp Page</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author Aniruddha Phadnis
 * @version 1.00
 * Created on Jul 18, 2005
 */

package edu.wustl.catissuecore.action;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

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

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

import edu.wustl.catissuecore.actionForm.ShoppingCartForm;
import edu.wustl.catissuecore.bizlogic.BizLogicFactory;
import edu.wustl.catissuecore.bizlogic.ShoppingCartBizLogic;
import edu.wustl.catissuecore.domain.Specimen;
import edu.wustl.catissuecore.query.ShoppingCart;
import edu.wustl.catissuecore.util.global.Constants;

public class ShoppingCartAction extends Action//BaseAction
{
    /**
     * Overrides the execute method of Action class.
     * Initializes the various fields in ShoppingCart.jsp Page.
     * */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException
    {
        //Gets the value of the operation parameter.
        String operation = (String)request.getParameter(Constants.OPERATION);
        
        HttpSession session = request.getSession(true);
        ShoppingCart cart = (ShoppingCart)session.getAttribute(Constants.SHOPPING_CART);
        ShoppingCartBizLogic bizLogic = (ShoppingCartBizLogic)BizLogicFactory.getBizLogic(Constants.SHOPPING_CART_FORM_ID);
        ShoppingCartForm shopForm = (ShoppingCartForm)form;
        
        if(cart == null)
        {
        	cart = new ShoppingCart();
        }
        
        if(operation == null)
        {
        	try
			{
        		List specimenList = bizLogic.retrieve(Specimen.class.getName());
        		Iterator it = specimenList.iterator();
        		
        		while(it.hasNext())
        		{
        			Specimen specimen = (Specimen)it.next();
        			cart.add(specimen);
        		}
        		
        		session.setAttribute(Constants.SHOPPING_CART,cart);
			}
        	catch(Exception e)
			{
        		e.printStackTrace();
			}
        }
        else
        {
	        if(operation.equals(Constants.ADD))
	        {
	        	//bizLogic.add(cart);
	        }
	        else if(operation.equals(Constants.DELETE))
	        {
	        	Map map = shopForm.getValues();
	        	Object obj[] = map.keySet().toArray();
	        	
	        	session.setAttribute(Constants.SHOPPING_CART,bizLogic.delete(cart,obj));
	        }
	        else if(operation.equals(Constants.EXPORT))
	        {
	        	//System.out.println("********************Real PATH : " + request.getRealPath(request.getContextPath()));
	        	//System.out.println("********************CONTEXT PATH : " + request.getContextPath());
	        	bizLogic.export(cart,"E:\\Program_Files\\jboss-4.0.0\\server\\default\\work\\Temp",session.getId());
	        }
        }
        
        //Sets the operation attribute to be used in the Add/Edit Shopping Cart Page. 
        request.setAttribute(Constants.OPERATION, operation);
        
        return mapping.findForward(Constants.SUCCESS);
    }
}
@@ -1148,16 +1148,70 @@
 stants;%0D
+%0Aimport edu.wustl.catissuecore.util.global.Variables;%0D
 %0A%0D%0Apubli
@@ -3172,322 +3172,199 @@
    %09
-//System.out.println(%22********************Real PATH : %22 + request.getRealPath(request.getContextPath()));%0D%0A%09        %09//System.out.println(%22********************CONTEXT PATH : %22 + request.getContextPath());%0D%0A%09        %09bizLogic.export(cart,%22E:%5C%5CProgram_Files%5C%5Cjboss-4.0.0%5C%5Cserver%5C%5Cdefault%5C%5Cwork%5C%5CTemp%22,session.getId()
+String fileName = session.getId() + %22.txt%22;%0D%0A%09        %09bizLogic.export(cart,Variables.catissueHome,fileName);%0D%0A%09        %09String path = %22/%22 + fileName;%0D%0A%09        %09return new ActionForward(path
 );%0D%0A

Change in shopping cart's file path