Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Web Application Deployment

Posted on 2004-08-17
2
Medium Priority
?
237 Views
Last Modified: 2010-04-17
Hi All,

In summary, my problem is

    Is it possble to maintain a static hash map between two web applications where one application updates the static map and the other retrieves data from it  ??


     When I tried it, I found that the two web apps access two different copies of the map. Therefore the updates from one web app is not visible to the other.

Thanks

Arshad
0
Comment
Question by:arshadsam
2 Comments
 
LVL 3

Accepted Solution

by:
kumvjuec earned 450 total points
ID: 11830100
hi,

how are you instantiating the map. And how are the jars (which contain your static map class) loaded in your classpath.
Are these jars different files or they are shared between the two projects.
Finally, are the two projects running on same server?? (most probably yes, isn't it)

Well, for the changes in the map to reflect, the class which has this static instance of the map must be shared, and they should be running on the same server, otherwise you will need to have ejb's in between. One standard way to share is to include both the web applications into a single ear file.
0
 

Author Comment

by:arshadsam
ID: 11837906
Eariler both web apps were the same. This problem came only after there were made seperate on a client requirement.

Yes both run in the same server.... (JBoss)
The static map is in a class that I created, part of which is shown below,

public class Users
{

     private static Hashtable lockedUsers = new Hashtable();
     private static InnerUsers bInstance = null; // This is a simple inner class to hold user details

     public static NDBUsers get()
     {
        if(bInstance == null)
            bInstance = new NDBUsers();
        return bInstance;
     }


    /**
     * constructor to get the details loaded from the database
     */
     protected NDBUsers()
     {
         PreparedStatement pstmt = null;
         ResultSet rs = null;
         Connection con = null;
         try
         {
             con = ConnectionManager.getConnection(this);
             if (bDebugMode) System.out.println("Before prepareStatement-------------------------");
             pstmt = con.prepareStatement("SELECT user_id,user_suffix,password,login_failure_count,user_type " +
                                          "FROM   ibk_users " +
                                          "WHERE  status_code = 1");
               if (bDebugMode) System.out.println("Before Executequery-------------------------");
             rs = pstmt.executeQuery();
             if (bDebugMode) System.out.println("after Executequery-------------------------");
             while (rs.next())
             {

             }
             if (bDebugMode) System.out.println("after loading users-------------------------");
         }
         catch(SQLException e)
         {
              System.out.println(e);
              e.printStackTrace();
         }
         finally
         {
             try
             {
                  if (rs != null) rs.close();
                  if(pstmt!=null)pstmt.close();
                  ConnectionManager.returnConnection(con);
             }
             catch (SQLException e1)
             {
                  System.out.println(e1);
                 ConnectionManager.returnConnection(con);
             }
         }
     }

     /**
     * Used to refresh the user details in memory.
     */

     class InnerUser
     {
         public String sPassword;
         public int iCount;
         public String sUserType;
         public boolean bLocked = false;

         public NDBUser (String sPassword1, int iCount1,String sUserType1)
         {
             this.sPassword   = sPassword1;
             this.iCount      = iCount1;
             this.sUserType   = sUserType1;
         }

         public void setLockedStatus(boolean bLocked)
         {
            this.bLocked = bLocked;
         }

         public boolean getLockedStatus()
         {
            return this.bLocked;
         }
     }

}


My project finally ends up in two war files. I would appreciate if U explain how I can share this static map. Consider me a novice to web application developement.

Regards and thanks
Arshad

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Starting up a Project

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question