Solved

Java Web Application Deployment

Posted on 2004-08-17
2
226 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 150 total points
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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.
A short article about problems I had with the new location API and permissions in Marshmallow
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now