Results 1 to 2 of 2
  1. #1
    anthrax is offline Member
    Join Date
    Feb 2009
    Posts
    57
    Rep Power
    0

    Default is it fine that my java programs sharing same JavaBean?

    i have 3 packages:

    package beanpackage;
    public class JavaBean {
    private String a = null;
    private String b = null;

    public JavaBean(String a, String b) {
    super();
    this.a = a;
    this.b = b;
    }
    public String getA() {
    return a;
    }
    public void setA(String a) {
    this.a = a;
    }
    public String getB() {
    return b;
    }
    public void setB(String b) {
    this.b = b;
    }

    }


    //######### another program A####
    package servlet_A;
    import beanpackage.JavaBean;

    private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    JavaBean bean = new JavaBean(request.getParameter("a"),request.getPara meter("b"));
    //more codes
    }


    //######### another program B####
    package servlet_B;
    import beanpackage.JavaBean;

    private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    JavaBean bean = new JavaBean(request.getParameter("c"),request.getPara meter("d"));
    //more codes
    }


    im worried that program B might change the data for program A or vise-versa or when program A stores its data to bean and program B is retrieving its data from bean.. program B will retrieve data from A.. are these instances possible ?
    Last edited by anthrax; 01-27-2010 at 05:39 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,997
    Rep Power
    19

    Default

    JavaBean is a class. Each of those servlets is creating an instance of that class. Each of those instances is different.

Similar Threads

  1. How to pass user-id between .java programs
    By mkkrish in forum AWT / Swing
    Replies: 4
    Last Post: 12-22-2009, 04:30 PM
  2. Java Programs to Test Performance
    By testarosa in forum Advanced Java
    Replies: 4
    Last Post: 02-27-2009, 01:04 PM
  3. Running 3 Java programs in sequence.
    By loktamu in forum New To Java
    Replies: 2
    Last Post: 11-23-2008, 06:50 PM
  4. application is not running please fine the solution for it.
    By jagadeeshchinni in forum New To Java
    Replies: 4
    Last Post: 09-28-2008, 10:14 AM
  5. Problem in running java programs
    By aravind in forum New To Java
    Replies: 0
    Last Post: 07-14-2008, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •