Solved

Java Web Application Deployment

Posted on 2004-08-17
2
232 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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 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…

631 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