First time to run it, console print out "get nothing" since no bean in the scope, but later on, there's bean with name = null, i.e., it didn't load data into the bean.
What's wrong w/ my code?
Joined: Jun 23, 2005
Since the bean is not null and the property "name" is null, it means that the request has no parameter with the name "name". Just try setting a "name" parameter in the request object before you forward it to the jsp.
When the user calls this single JSP what happens is: a html form with a input text will be shown in the browser, in the server a bean called employee will be created if it doesn't exists in the session; only if the bean is being created all its properties will be set according to the current request parameters.
Then, when in the browser you click the submit button you will be calling the servlet directly and not the JSP, so, since the JSP will be called once your parameters (only the 'name' parameter in fact) will never be set in the bean.
To achieve the result you want you should remove the jsp:setProperty from the body of the jsp:useBean and submit the html form to the same JSP before going to the servlet.
I hope this help. I'm sure that there are better ways to do that besides the one I exemplified to you.
subject: pass bean from jsp:setProperty to servlet?