Hi all, I read the following concept from the Head First Servlets and JSP book (second edition)(page 420) The following is an abstract Bean class person
The following is the subclass of Person
The following is the standard action in a jsp file
The following is the servlet code
Now coming to my problem The book says The servlet code FAILS at request time,The person attribute is stored at request scope,so the <jsp:useBean>tag won't work since it specifies only a type.The Container KNOWS that if you have only a type specified there must be an existing attribute of that name and scope
My doubt is
1.How the servlet code is linked to the jsp page I mean there is no form action tag given here?[/B
2.[B]What is request time ?
3.How is the person attribute's scope related to the type of the useBean tag
It is fairly obvious if you invoke the jsp directly, you will get a runtime error, because the bean "person" is not in scope, and it can't create one on the fly.
The servlet's responsibility is to set up the "person" bean, so that the jsp can use it.
What links the two? What tells it to run the servlet first and then the JSP? And which JSP? That is normally the job of a "controller"
Normally code something like this:
If this was in your servlet it would tell it to forward to the jsp "fooTest.jsp" once it was finished processing.
The HttpRequest is triggered by exactly that. A client (normally a browser) making a request of the server. The server receives the connection from the browser, creates an HttpServletRequest object for you to use, and then invokes the servlet/jsp which was referenced, passing in the request object as a parameter. This is all done by the servlet container.
Request scope is the scope of one request-response cycle. Ie the server receives a request from the browser, and sends back a response. Session scope (by contrast) can go over multiple requests from the same user. You can specify any of the 4 attribute scopes for a bean to "live" in and it will look for it there.
posted 11 years ago
Thank you Mr.Stefan Evans I have solved that problem........
30 seconds to difuse a loaf of bread ... here, use this tiny ad: