So what else could be the way to use the request attribute for the code above?? I want to set the attribute in the jsp and get it in the servlet. Should I get a request dispatcher and forward the request and response or Should I store this as a session attribute which I don't want since I'm not going to use session for the above example?? [ April 26, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
The question is when I set the request attribute in a jsp and when hitting the submit button, the jsp calls a servlet and in that servlet, I'm trying to get the values of the attribute using getAttribute method and when I tried this, it gave me NullPointerException. I later understood that when the service method of the jsp finishes the request attributes gets vanished which is why I'm getting a null pointer. So like you say when I use a hidden field it is again the same or??
You can't, because the request is generated by the web client after submission. You can do it with servlet->jsp, not jsp->servlet. If you need to store something beyong the scope of a request, then you'll have to put it in session or application scope.