wrote:
> Hi all,
> In the below code i am instantiating the request and session object at
> the class level.But i am getting Null Pointer Exception while
> instantiating.
That's because you're not instantiating:
HttpServletRequest request; // Returns Null Pointer Exception
This line doesn't instantiate a HttpServletRequest instance - it merely
declares the type of a reference called 'request' that can be used to
refer to an HttpServletRequest instance (or a subclass instance). In
Java you use 'new' to make a new instance of an object:
Integer int = new Integer(7);
From your code it seems you don't have a very good understanding of
servlets. That can be fixed easily enough, but you have to go and do
some studying - I think that you need to work on your basic Java skills
before even thinking about things like Servlets. So forget servlets,
polish up your plain old Java knowledge first.
There's a tonne of free resources on the web for learning Java (e.g.
Sun's site) - go and reap the fruits!
alex