Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java Web Application Deployment

Posted on 2004-08-17
2
Medium Priority
?
235 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
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 …
Simple Linear Regression

715 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