I got a “null pointer exception” fault in java servlet. Could someone tell me what happens? And how to avoid that?
I know java servlet can be used as part of a hybrid solution, could support many different programming languages. How would the different programs execute/call each other and exchange information? (could someone tell me some words but codes). In addition, values extracted from a session object have to be converted(cast) to a specific type, but why?
For example, how can I store a variable of type “int” in a session object. Could someone help me to figure it out?
That happens when you’re trying to access/invoke some reference which is actually
null.You need to make sure that you only access/invoke it when it is not
null.It’s just matter of logical thinking and understanding basic Java.
Pass them as method parameter(s).
Use
Integerinstead and/or profit Java 1.5’s autoboxing capabilities.