Solved

Java Web Application Deployment

Posted on 2004-08-17
2
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
kumvjuec earned 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp Google Map 2 93
troubleshoot a python script 8 117
Java ArrayList and if statement 2 55
Eclipse neon2 "Java build path" correctness 7 44
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

752 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