package JavaUtil;

import java.io.IOException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import juno2Beans.acctList.CmdAccountList;
import juno2Beans.acctList.CmdAccountListHome;

import Juno2.AccountListCVO;


public class runBean extends HttpServlet {

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {

		super.doGet(req, resp);
		
		CmdAccountListHome  m_home;
		CmdAccountList	cml;
		
      	try{
            Context ic=new InitialContext();

            Object obj=ic.lookup("ejb/juno2Beans/CmdAccountListHome");
            m_home =(CmdAccountListHome)javax.rmi.PortableRemoteObject.narrow(obj,CmdAccountListHome.class);
            System.out.println("Lookup is fine");
                  
            cml = m_home.create();
            //hardcoded userid and password for testing purposes. 
            //This value should be coming froma form.      
            AccountListCVO  alcvo = cml.doAccountList("0SQLSDDH05", "0SQLSDDH05");
            
			System.out.println("***Printing from within RunBEAN of servlet***");
			System.out.println("***Printing from within RUNCMDAccountEJB***");
        	String strFirstName = alcvo.getFirstName();
        	String strLastName = alcvo.getLastName();
     
			System.out.println("the first name is :" + strFirstName);
			System.out.println("the last name is :" + strLastName);
                  
		}catch(Exception ex)
            {
                  System.out.println("Lookup failed");
                  ex.printStackTrace();
            }
		}


		
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {

		super.doPost(req, resp);

	}

}
