This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I'm setting the properties of a bean from some get request parameters in a servlet, and using a request dispatcher to forward the request to a jsp page. I'm using the bean in the jsp page, but when I try and retreive the values from the bean, they are null. I've set the bean as a session bean, is there something I'm missing. Richard
yo richy!! i'll drop you an e-mail to catch up. What I think is your problem is the scope of your javabean, make it scope="request" in your to and from jsp's. Alternatively, keep it session, and implicily set the javabeans properties in the destination jsp page from the request(to do this your input field names have to match up with your javabean variables) -and you'll have the bonus of not having to set them in your servlet later, Greg
It sounds like your JSP is building a new bean instead of using the one attached to the session. Are you sure you are using the same name in both JSP and servlet? Bill
Joined: May 25, 2001
Hey guys, Thanks for your replies. Greg, I didn't know you where still spreading your knowledge, good to hear from you. I don't think i explained myself so here goes... In my servlet, I am creating an instance of a bean, populating the variables from a get request and then I use: HttpSession session = request.getSession(true); session.putValue("transformer", transformerBean); In the jsp page, I have the following: <jsp:useBean id="transformer" class="TransformerBean" scope="application" /> Except now I get the error: Attempted a bean operation on a null object So I assume I'm missing something somewhere, probably in the servlet. Richard