<% Connection con=db.getconnection(); %> Friend's im confused with the scope element here,In this example im declaring the scope to be application. So ,will I be able to use my bean in all my other jsp files ,without using <jsp:usebean> tag in those pages. But its not working,Pls advice me on this.If the scope is not mean for something like this ,then what's it for?
The scope in which the Bean exists and the variable named in id is available. The default value is page. The meanings of the different scopes are shown below:
page - You can use the Bean within the JSP page with the <jsp:useBean> element or any of the page's static include files, until the page sends a response back to the client or forwards a request to another file.
request - You can use the Bean from any JSP page processing the same request, until a JSP page sends a response to the client or forwards the request to another file. You can use the request object to access the Bean, for example, request.getAttribute(beanInstanceName).
session - You can use the Bean from any JSP page in the same session as the JSP page that created the Bean. The Bean exists across the entire session, and any page that participates in the session can use it. The page in which you create the Bean must have a <%@ page %> directive with session=true.
application - You can use the Bean from any JSP page in the same application as the JSP page that created the Bean. The Bean exists across an entire JSP application, and any page in the application can use the Bean.
You have wrongly interpreteted my question ,My question is simple Should I use the <jsp:usebean> tag in every page where im using the bean or not, Ater declaring the scope to be "application" I have declared my bean scope as application in my first page.But in my second page unless,I write the <jsp:usebean>tag once again im not able to acess the bean,What may be the problem??
Your understanding of the useBean tag is faulty. The scope you declare controls the accessibilty and lifetime of the bean. You must still use the useBean action on each page to "hook up" the bean to the id with which it will be referenced on the page.