Discussions

Web tier: servlets, JSP, Web frameworks: JSP programming in JDeveloper

  1. JSP programming in JDeveloper (1 messages)

    Hi,
     we are developing a jsp business application,we are using Jdeveloper as the tool.but we want to customize the components provided by them.

    can anybody tell me which is the best soultion customizing the web data beans providing or writing them from scratch.

    thx in advance
    murali
  2. hi,
    my question is how can i access the data when it is disconnected
    my choice is ejb for that
     and i make some thing which i paste over here can any one help me

    ************************************************************

    package Safebean;

    import javax.ejb.*;
    import java.util.*;
    import java.sql.*;
    import javx.naming.*;
    import java.sql.*;
    import java.lang.*;
    import safe.index1.*;

    public SafeBMPBean implements EntityBean
    {
    EntityContext entityContext;
    String P_name,txt_code,add1,add2,add3,pincode,city,pan_no,cst_no,con_person,email,che_credit,che_topay,cc_credit;
    String sh="";

    String username=(String)session.getAttribute("uname");
    String year=(String)session.getAttribute("year");
    String n_month=(String)session.getAttribute("n_month");
    String date=(String)session.getAttribute("date");

    Vector vc=new Vector();
    indexBean inbean=new indexBean();

    private transient EntityContext mContext=null;

    Connection conn=null;
    Statement st=null;
    ResultSet rs=null;

    if((Connection)session.getAttribute("conn")!=null)
    {
    conn=((Connection)session.getAttribute("conn"));
    }
    else
    {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn=DriverManager.getConnection("jdbc:oracle:thin:@corp-it:1521:orcl","vnegi","vnegi123");
    session.setAttribute("conn",conn);
    }

    public String ejbCreate(String p_code) throws CreateException
    {

    try{
       st=con.createStatement();
    rs=st.executeQuery(sql);
    partyname=inbean.getP_name();
    counter=inbean.gettxt_code();
    ii= Integer.parseInt(counter.trim());
     add1=inbean.getadd1();
     add2=inbean.getadd2();
     add3=inbean.getadd3();
     pincode=inbean.getpincode();
     city=inbean.getcity();
      pan_no=inbean.getpan_no();
      cst_no=inbean.getcst_no();
      con_person=inbean.getcon_person();
     email=inbean.getemail();
     ccc_code=inbean.getcc_credit();
     che_topay=inbean.getche_topay();
      che_credit=inbean.getche_credit();
    String cr_yn;

    if(che_credit.equals("null"))
    {
    cr_yn="N";
         }
    else
    {
    cr_yn="Y";
    }


    String topay_yn;
    if(che_topay.equals("null"))
    {
    topay_yn="N";
    }
    else
    {
    topay_yn="Y";
    }

    if(e_month.equals("1"))
    {
    e_month="Jan";
    }
    else if(e_month.equals("2"))
    {
    e_month="Feb";
    }
    else if(e_month.equals("3"))
    {
    e_month="Mar";
    }
    else if(e_month.equals("4"))
    {
    e_month="Apr";
    }
    else if(e_month.equals("5"))
    {
    e_month="May";
    }
    else if(e_month.equals("6"))
    {
    e_month="Jun";
    }
    else if(e_month.equals("7"))
    {
    e_month="Jul";
    }
    else if(e_month.equals("8"))
    {
    e_month="Aug";
    }
    else if(e_month.equals("9"))
    {
    e_month="Sep";
    }
    else if(e_month.equals("10"))
    {
    e_month="Oct";
    }
    else if(e_month.equals("11"))
    {
    e_month="Nov";
    }
    else
    {
    e_month="Dec";
    }

    String sqls="";
    String sqls1="";
    int rowcount;
    int comm=0;
    int per_pack=0;
    int per_ton=0;
    sqls="insert into Partymas values('','','','"+ii+"','"+partyname+"','c','"+add1+"','"+add2+"','"+add3+"','"+pincode+"','"+email+"','"+cst_no+"','"+con_person+"','"+pan_no+"',"+comm+","+per_pack+","+per_ton+",'','"+e_date+"-"+e_month+"-"+e_year+"','"+username+"','','','"+city+"','"+cr_yn+"','"+topay_yn+"','','','"+ccc_code+"')";

    st.executeQuery(sqls);
    return p_code;
    }
    catch(SQLException e)
    {
    e.printStackTrace();
    throw new CreateException();
    }
    catch(NamingException e)
    {
    e.printStackTrace();
    throw new CreateException();
    }

    }
    public String ejbActivate() throws EJBException,RemoteException
    {


    }
    public void ejbLoad()throws EJBException,RemoteException
    {
    try
    {


    loadFromDB();


    }catch(Exception e)
    {
    System.out.println("Failed to load Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbLoad failed :-",e);
    }

    }

    public void ejbStore()throws EJBException,RemoteException
    {
    try
    {
    loadtoDB();

    }catch(Exception e)
    {
    System.out.println("Failed to Store Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbStore failed :-",e);
    }

    }
    public void ejbPassivate()throws EJBException,RemoteException
    {
    }
    public void ejbPostCreate()
    {


    }
    public void ejbRemove()
    {

    String pcode=inbean.gettxt_code();
    String str="delete from partymas where party_code like '"+pcode+"'";
    st.executeQuery(str);


    }
    public Vector ejbFindByPrimaryKey(String p_code)throws RemoteException,FinderException
    {
    try
    {
    Vector vc=new Vector();
    sql="select * from partymas where party_code='"+p_code+"'";
    st=con.createStatement();
    rs=st.executeQuery(sql);
    ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();

    while(rs.next())
    {
    for(int i=1; i<=cols; i++)
    {
    Object value = rs.getObject(i);
    vc.add(value);
    }
    return vc;
    }
    }catch(SQLException e)
    {
    System.out.println("Failed to getByPrimary Key Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbFindByPrimaryKey failed :-e);
    }
    }
    public void ejbFindByName(String p_name)throws RemoteException,FinderException
    {
    try
    {
    Vector vc=new Vector();
    sql="select * from partymas where party_name='"+p_name+"'";
    st=con.createStatement();
    rs=st.executeQuery(sql);
    ResultSetMetaData rsmd = rs.getMetaData();
    int cols = rsmd.getColumnCount();

    while(rs.next())
    {
    for(int i=1; i<=cols; i++)
    {
    Object value = rs.getObject(i);
    vc.add(value);
       }
    return vc;
    }
    }catch(SQLException e)
    {
    System.out.println("Failed to getByPrimary Key Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbFindByPrimaryKey failed :-",e);
    }

    }
    public void ejbFindByCity(String city)throws RemoteException,FinderException
    {
    try
    {
    Vector vc=new Vector();
    sql="select * from partymas where station_code='"+city+"'";
    st=con.createStatement();
    rs=st.executeQuery(sql);
    ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();

    while(rs.next())
    {
    for(int i=1; i<=cols; i++)
    {
    Object value = rs.getObject(i);
    vc.add(value);
    }
    return vc;
    }
    }catch(SQLException e)
    {
    System.out.println("Failed to getByPrimary Key Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbFindByPrimaryKey failed :-",e);
    }

    }
    public Vector loadFromDB()
    {
    try
    {
    Statement st,st1=null;
    ResultSet rs=null;

    st=conn.createStatement();
    String sqls1="select * from Partymas order by to_number(party_code)";
    rs=st.executeQuery(sqls1);

    ResultSetMetaData rsmd = rs.getMetaData();
    int cols = rsmd.getColumnCount();

    while (rs.next())
    {
    for(int i=1; i<=cols; i++)
    {
    Object value = rs.getObject(i);
    vc.add(value);
    }
    return vc;
    }
    }catch(Exception e)
    {
    System.out.println("Failed to load Bean :-");
    e.printStackTrace();
    throw new RemoteException("ejbLoad failed :-",e);
    }

    }
    public void loadtoDB()
    {

    String partyname=inbean.getP_name();
    String add1=inbean.getadd1();
    String add2=inbean.getadd2();
    String add3=inbean.getadd3();
    String pincode=inbean.getpincode();
    String city=inbean.getcity();
    String pan_no=inbean.getpan_no();
    String cst_no=inbean.getcst_no();
    String con_person=inbean.getcon_person();
    String email=inbean.getemail();
    String topay_yn=inbean.getche_topay();
    String cr_yn=inbean.getche_credit();
    String cc_credit=inbean.getcc_credit();

    String m_mon;
    if(m_month==1)
    {
    m_mon="Jan";
    }
    else if(m_month==2)
    {
    m_mon="Feb";
    }
    else if(m_month==3)
    {
    m_mon="Mar";
    }
    else if(m_month==4)
    {
    m_mon="Apr";
    }
    else if(m_month==5)
    {
    m_mon="May";
    }
    else if(m_month==6)
    {
    m_mon="Jun";
    }
    else if(m_month==7)
    {
    m_mon="Jul";
    }
    else if(m_month==8)
    {
    m_mon="Aug";
    }
    else if(m_month==9)
    {
    m_mon="Sep";
    }
    else if(m_month==10)
    {
    m_mon="Oct";
    }
    else if(m_month==11)
    {
    m_mon="Nov";
    }
    else
                                      {
                                      m_mon="Dec";
                                        }

    String sqls="";

    sqls="update partymas set party_name='"+partyname+"',add1='"+add1+"',add2='"+add2+"',add3='"+add3+"',pin_code='"+pincode+"',Station_code='"+city+"',pan_no='"+pan_no+"',cst_no='"+cst_no+"',contact_per='"+con_person+"',email='"+email+"',cr_yn='"+cr_yn+"',topay_yn='"+topay_yn+"',ccc_code='"+ccc_code+"',modify_date='"+m_date+"-"+m_mon+"-"+m_year+"',modify_by='"+username+"' where party_code = '"+partycode+"' and party_name='"+partyname+"'";

    st.executeUpdate(sqls);
    }
    public void unsetEntityContext()
    {
    this.entityContext=null;
    }

    public void setEntityContext(EntityContext entityContext)
    {
    this.entityContext=entityContext;
    }

    }
    my home and remote methods are as follows

    package Safebean;

    import javax.ejb.*;
    import java.util.*;

    public interface Safehome extends javax.ejb.EJBLocalHome
    {
    //public SafeBMP ejbCreate(String P_name,String p_code,String add1,String add2,String add3,String pincode,String city,String pan_no,String cst_no,String con_person,String email,String che_credit,String che_topay,String cc_credit) throws CreateException;
    public SafeBMP ejbCreate(String p_code) throws CreateException;
    public SafeBMP findNext(String P_name) throws FinderExceptoin;
    public SafeBMP findFirst(String P_name) throws FinderExceptoin;
    public SafeBMP findlast(String P_name) throws FinderExceptoin;
    public SafeBMP findPrevious(String P_name) throws FinderExceptoin;
    public SafeBMP findByPrimaryKey(String p_code) throws FinderExceptoin;
    public SafeBMP findByName(String p_name) throws FinderExceptoin;
    public SafeBMP findByCity(String city) throws FinderExceptoin;
    }
    ****************************

    package Safebean;

    import javax.ejb.*;
    import java.util.*;
    import java.rmi.*;
    import java.sql.*;
    import java.math.*;

    public interface SafeRemote extends javax.ejb.EJBObject
    {
    public String getP_name() throws RemoteException;
    public void setP_name(String P_name) throws RemoteException;
    public String gettxt_code() throws RemoteException;
    public void settxt_code(String txt_code) throws RemoteException;
    public String getadd1() throws RemoteException;
    public void setadd1(String add1) throws RemoteException;
    public String getadd2() throws RemoteException;
    public void setadd2(String add2) throws RemoteException;
    public String getadd3() throws RemoteException;
    public void setadd3(String add3) throws RemoteException;
    public String getpincode() throws RemoteException;
    public void setpincode(String pincode) throws RemoteException;
    public String getcity() throws RemoteException;
    public void setcity(String city) throws RemoteException;
    public String getpan_no() throws RemoteException;
    public void setpan_no(String pan_no) throws RemoteException;
    public String getcst_no() throws RemoteException;
    public void setcst_no(String cst_no) throws RemoteException;
    public String getcon_person() throws RemoteException;
    public void setcon_person(String con_person) throws RemoteException;
    public String getemail() throws RemoteException;
    public void setemail(String email) throws RemoteException;
    public String getche_credit() throws RemoteException;
    public void setche_credit(String che_credit) throws RemoteException;
    public String getche_topay() throws RemoteException;
    public void setche_topay(String che_topay) throws RemoteException;
    public String getcc_credit() throws RemoteException;
    public void setcc_credit(String cc_credit) throws RemoteException;

    }

    package safe.index1;


    public class indexBean
    {

      String P_name="";
      public void setP_name(String P_name)
      {
        this.P_name=P_name;
      }
       public String getP_name()
      {
         return P_name;
     }


     String txt_code="";
     public void settxt_code(String txt_code)
     {
    this.txt_code=txt_code;
     }
     public String gettxt_code()
     {
    return txt_code;
     }


       String add1="";
     public void setadd1(String add1)
      {
        this.add1=add1;
      }
      public String getadd1()
      {
         return add1;
     }


     String add2="";
       public void setadd2(String add2)
      {
        this.add2=add2;
      }
      public String getadd2()
      {
         return add2;
     }


     String add3="";
       public void setadd3(String add3)
    {
        this.add3=add3;
      }
      public String getadd3()
      {
         return add3;
     }


     String pincode="";
     public void setpincode(String pincode)
     {
         this.pincode=pincode;
       }
       public String getpincode()
       {
          return pincode;
      }


    String city="";
      public void setcity(String city)
     {
         this.city=city;
       }
       public String getcity()
       {
          return city;
      }


       String pan_no="";
       public void setpan_no(String pan_no)
        {
            this.pan_no=pan_no;
          }
          public String getpan_no()
          {
             return pan_no;
         }


    String cst_no="";
        public void setcst_no(String cst_no)
        {
            this.cst_no=cst_no;
          }
          public String getcst_no()
          {
             return cst_no;
         }


          String con_person ="";
    public void setcon_person(String con_person)
    {
    this.con_person=con_person;
    }
    public String getcon_person()
    {
             return con_person;
    }


    String email="";
    public void setemail(String email)
    {
    this.email=email;
    }
    public String getemail()
    {
             return email;
    }


    String che_credit="";
    public void setche_credit(String che_credit)
    {
    this.che_credit=che_credit;
    }
    public String getche_credit()
    {
             return che_credit;
    }



    String che_topay="";
    public void setche_topay(String che_topay)
    {
    this.che_topay=che_topay;
    }
    public String getche_topay()
    {
             return che_topay;
    }


    String cc_credit="";
    public void setcc_credit(String cc_credit)
    {
    this.cc_credit=cc_credit;
    }
    public String getcc_credit()
    {
             return cc_credit;
    }
    String zone_code="";
    public void setzone_code(String zone_code)
    {
    this.zone_code=zone_code;
    }
    public String getzone_code()
    {
             return zone_code;
    }
    String region_code="";
    public void setregion_code(String region_code)
    {
    this.region_code=region_code;
    }
    public String getregion_code()
    {
    return region_code;
    }
    String branch_code="";
    public void setbranch_code(String branch_code)
    {
    this.branch_code=branch_code;
    }
    public String getbranch_code()
    {
    return branch_code;
    }
    String party_type="";
    public void setparty_type(String party_type)
    {
    this.party_type=party_type;
    }
    public String getparty_type()
    {
    return party_type;
    }
    double comm="";
    public void setcomm(double comm)
    {
    this.comm=comm;
    }
    public double getcomm()
    {
    return comm;
    }
    double per_pack="";
    public void setper_pack(double per_pack)
    {
    this.per_pack=per_pack;
    }
    public double getper_pack()
    {
    return per_pack;
    }
    double per_ton="";
    public void setper_ton(double per_ton)
    {
    this.per_ton=per_ton;
    }
    public double getper_ton()
    {
    return per_ton;
    }
    char all_india="";
    public void setall_india(char all_india)
    {
    this.all_india=all_india;
    }
    public char getall_india()
    {
    return all_india;
    }
    String ent_date="";
    public void setent_date(char ent_date)
    {
    this.ent_date=ent_date;
    }
    public String getent_date()
    {
    return ent_date;
    }
    String user_name="";
    public void setuser_name(String user_name)
    {
    this.user_name=user_name;
    }
    public char getuser_name()
    {
    return user_name;
    }
    String modify_by="";
    public void setmodify_by(String modify_by)
    {
    this.modify_by=modify_by;
    }
    public char getmodify_by()
    {
    return modify_by;
    }
    String modify_date="";
    public void setmodify_date(String modify_date)
    {
    this.modify_date=modify_date;
    }
    public char getmodify_date()
    {
    return modify_date;
    }
    String Phone="";
    public void setPhone(String Phone)
    {
    this.Phone=Phone;
    }
    public char getPhone()
    {
    return Phone;
    }
    String Fax="";
    public void setFax(String Fax)
    {
    this.Fax=Fax;
    }
    public char getFax()
    {
    return Fax;
    }

    }

    now tell me the solution what should i do after that