top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to maintain a static object list in Java??

+2 votes
865 views

I am working on an app with Java and Struts2.
I fetch all data from my DB to an Object(eg.XXX) List at once while Tomcat(7) is coming up. Then according to user selection, I am trying to get data from the same List by doing Ajax call. But it is failing and getting an empty list. I don't want to use session.
Can I use and global object list for this?? An Example will be more helpful.

posted Sep 10, 2013 by Satyabrata Mahapatra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Java does not have global variable, but the same can be achieved by the static members. But that will not solve your problem it seems.
Oh sorry.. what i mean was "public" object" ??
Not able to get the question, can you please edit your question...

2 Answers

+2 votes
 
Best answer

I would say try to solve the Ajax problem,
even if you want to try the global variable/object try in the following way -

public class Global {
  public static int a;
  public static int b;
}

now you can access a and b from anywhere by calling

Global.a;
Global.b;
answer Sep 10, 2013 by anonymous
+1 vote

So this is what i am doing now.

public class AppABC {
    public static List<XXX> xxxList = new ArrayList<XXX>();
}

And i am calling it as

AppABC.xxxList 
answer Sep 10, 2013 by Satyabrata Mahapatra
Similar Questions
+7 votes

I have just launched a website at http://www.csiiitn.com , Its main asset is Technical Discussion Forum. It totally based on hashchange links. I want to create sitemap(XML File) for my website and submit to Google. Is there anyone that know how to do that? Or is there any online service providers??

+1 vote

I am using Apache2.2.22 on a Debian7 server. Hosting multiple websites, but have reduced it to just one for now to try to figure out this problem.

So, if I go to: www.mysite.com the website shows up. HOWEVER, if I go to just: mysite.com from outside our company network, I get the error "Forbidden. You don't have permission to access / on this server."

From inside the company network, however, it works fine. Here is the only file in /etc/apache2/sites-enabled

NameVirtualHost *:80
 ServerAdmin abc@abc.com

 DocumentRoot /var/www/mysite
 ServerName www.mysite.com
 ServerAlias mysite.com

 Options FollowSymLinks
 AllowOverride None

 Options FollowSymLinks
 AllowOverride None
 Order allow,deny
 allow from all
 # This directive allows us to have apache2's default start  page
 # in /apache2-default/, but still have / go to the right place
 #RedirectMatch ^/$ /apache2-default/

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

 AllowOverride None
 Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
 Order allow,deny
 Allow from all

 ErrorLog /var/log/apache2/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

 Alias /doc/ "/usr/share/doc/"

 Options Indexes MultiViews FollowSymLinks
 AllowOverride None
 Order deny,allow
 Deny from all
 Allow from 127.0.0.0/255.0.0.0 ::1/128
+1 vote

The Barracuda load balancer has feature which enables it to recover a broken web connection. Let me explain the scenario; suppose that there exist two web servers behind the Barracuda load balancer and the user is downloading a file from one of the back-end web servers. Now, suppose that the active web server goes down, the Barracuda load balancer is capable of continuing the download from where it was broken using the other web server. Is it possible to achieve such a behaviour using mod_proxy_balancer? Are there exist any open source alternatives which can provide the same capability? If not, is anybody aware of any roadmap to achieve the same functionality using open source tools? Considering mod_proxy_balancer, what are the required steps to follow in order to add such a functionality?

...