Assuming you have a fixed set of images. Then you would be better storing these on the file system, and have your (caching) web-server/application server serve them based on a dynamically generated path - it'll be quicker and more efficient. So your jsp, or something similar will build up the img tag path to point to the image required at that time.
Even if you are generating images that only exist for a user's session, it is still probably a bad idea to store them in the session as it will make your session graphs potentially big, could cause problems with synchronised sessions in a clustered environment, performance issues where sessions are written to and from file, etc. It would be better to store them on the file system in a temporary file. Dont forget to clean-up if they become invalid.
I dont think this works, and I bet it's not thread safe.
Singletons are tricky. You should know why you want a singleton and how it is used (per JVM, per cluster, per ???). Is this to manage some globale resource, or to prevent unneccessary objects with no internal state?
Those discussions beside, look at the discussions in the following links for a better understanding of the issues.
There are lotes of different kinds of server (anything that responds to a client). But what I think you want to know is this:
Web server - think Apache servers up web content (HTML, etc) and can be extended with plugins (CGI, PHP, etc.)
Servlet Container - e.g. Tomcat, hosts servlets/jsps and used to serve dynamic content (usually to http clients)
EJB container - Used to host EJBs and can serve many clients.
Application server - Weblogic, Websphere, Glassfish, JBoss, etc. Typically consists of a web server, servlet container and EJB container. Often provides other stuff as well.
Depending on your needs, you would use some or all of the servers available. If you only have static content, then a web server will do. You can often implement all of an application using JSP/Servlets (and maybe a web server upfront). Occasionally, you will have a large scale, transactional system and you could use an EJB container (probably with the other servers as well).
You need to think about what the access modifiers (like private) mean. Why are these a good idea, when might you want to use them? You should also check out the behaviour when it comes to inheritance.
Often, people talk about making class members private, to force access through methods. This serves 2 purposes - as the author of the access method(s), you can add rules, validation, etc., you can also protect the user of the method from the actual type you use to store the data in (this means you could change the member type without affecting callers. A godd example would be the Collections classes. Do you know (or care) if the underlying store is an array, or some other object?
So thats a good reason for things being private, but there are times when that wouldn't make sense - Math.PI will always be the same value so thers no point hiding it!
Lastly, if you dont want your member to change, make it final and intialise it before anyone else can.
Just to add to those comments already made. If you are overriding the equals method, you should meet the contract specified in the API documentation for java.lang.Object. If there are other meaningful tests for equality include those. This is most common in data objects
For example an employee object using the equals method from Object would only return true if 2 instances they referred to the same object. It would be preferrable to have equals return true of the instances referred to the same employee (one test may be equality on the NI/social securtiy number, or maybe the employee number, etc).
When posting code please use the code tags. This will preserve formatting and make it easier to read. I suggest you take a closer look at Stan's posting, then at your code. The compiler will tell you roughly where the problem occurred. If you are still stuck then, come back.
Perhaps you could describe what the client is asking for. The point being, why should a client want disparate information all one call? In the example you give, if it is reasonalbe for the client to have all this data, why not pass the args String and let the client do the conversion?
Describe your problem in more general terms and it may help find the correct solution. Alternatively post some code, so we can see what you are trying to do.
Sorry to cover old ground, but I couldnt see any specific answer.
I have 2 Win XP pro machines (pc and laptop). Ultimately, I wish to invoke a web service running in oc4j 10.1.2 on machine A, that will delegate to a RMI client that will invoke a RMI server running in Tomcat 5 on machine B.
I have written an RMI server and RMI client. I run the RMI Server (machine B) on my pc. I can then invoke the service running the client as a standalone. Both are using a blanket 'anything goes' security policy. I see output at both ends - so far so good.
I next generated a web service from the RMI client using JDeveloper. I deployed the web service to oc4j running on machine A. The web service deploys fine, and I can invoke the service using the supplied oc4j forms. However, I get a java.rmi.ConnectException when doing the Naming.lookup() call.
FYI, I have overidden RMISecurityManager, although I am not sure this is the best approach. Below is what I believe to be the pertinent code. I presume this is a configuration issue but cant think what. Thank you all in adavnce for your help
[ August 09, 2006: Message edited by: Ramen Chatterjee ]
Ive been following this thread. It would certainly help (me at least) if you could describe the problem in terms of the 'real world'. That is, you are trying to solve a problem (the why) and have mentioned one (potential) way of solving that problem (the how). If you could describe 'the why' a bit more, it may help answer your problem.