I thought I should get the output: First page: ok Second page: ok
I think this is what's happening. (You can probably verify this by looking at the java source code generated by Tomcat from your JSP):
When you do a <jsp:useBean> and declare where the bean lives, the translator essentially converts that to this line of code:
String bandBg = (String)request.getAttribute("bandBg");
Then, later, you are using a scriptlet to do this:
bandBg = "ok";
In the other JSP, the same code executes:
String bandBg = (String)request.getAttribute("bandBg");
However, you never poked 'ok' back into the request, so it's still either null or blank or whatever it was when you started.
Setting the local reference bandBg in your Page1.jsp doesn't do anything outside of it. You'd have to do something like this in your scriptlet to make it work:
<% request.setAttribute("bandBg", "ok"); %>
If you're going to use <jsp:useBean>, you probably shouldn't screw around with those variables inside of scriptlets. Try to stick with the bean tags only. That generally means that you'll have to write your own bean instead of using a string (so it can have a 'setValue' method or something).
Hope that helps.
-chris
signature.asc
Description: OpenPGP digital signature
