Store it in session and when you are done with it, remove it with session.removeAttribute("name of bean")
Ron Day Senior Developer e-Rewards, Inc. 8401 N. Central Expressway, Suite 900 Dallas, TX 75225 Voice: 214.782.2834 Fax: 214.782.2900 -----Original Message----- From: Mark Whitby [mailto:[EMAIL PROTECTED] Sent: Thursday, March 02, 2006 2:24 PM To: Tomcat Users List Subject: Re: - Problems with extracting beans from a JavaServer Page Thanks Ron, I've now changed it to store the item both in the session and the request and this has done the trick. I store it in the request for the jsp page and in the httpsession for the following bean. Or is this inefficient? Mark ----- Original Message ----- From: "Day, Ron" <[EMAIL PROTECTED]> To: "Tomcat Users List" <users@tomcat.apache.org> Sent: Thursday, March 02, 2006 8:16 PM Subject: RE: - Problems with extracting beans from a JavaServer Page Yes, if I interpreted your code correctly. The "scope" attribute determines where the bean is stored, i.e. in what object. Ron Day Senior Developer e-Rewards, Inc. 8401 N. Central Expressway, Suite 900 Dallas, TX 75225 Voice: 214.782.2834 Fax: 214.782.2900 -----Original Message----- From: Mark Whitby [mailto:[EMAIL PROTECTED] Sent: Thursday, March 02, 2006 2:00 PM To: Tomcat Users List Subject: Re: - Problems with extracting beans from a JavaServer Page Thanks for the reply Ron So what you're saying is that once the page has loaded the bean, it discards it? Which means I can send a bean from a servlet to a page but I can't extract a bean from a page? Is that correct based on my code? So what I'm thinking now is to store the bean in the session.setAttribute method, would that save the bean and allow me to extract it in another servlet? Mark ----- Original Message ----- From: "Day, Ron" <[EMAIL PROTECTED]> To: "Tomcat Users List" <users@tomcat.apache.org> Sent: Thursday, March 02, 2006 7:56 PM Subject: RE: [SPAM] - Problems with extracting beans from a JavaServer Page - Bayesian Filter detected spam If I have followed your code fragments correctly, it looks like your bean is in request scope and it will go away between requests. Ron Day Senior Developer e-Rewards, Inc. 8401 N. Central Expressway, Suite 900 Dallas, TX 75225 Voice: 214.782.2834 Fax: 214.782.2900 -----Original Message----- From: Mark Whitby [mailto:[EMAIL PROTECTED] Sent: Thursday, March 02, 2006 1:47 PM To: Tomcat Users List Subject: [SPAM] - Problems with extracting beans from a JavaServer Page - Bayesian Filter detected spam Hey all, This may seem like a really dense question so apologies if it is but I have the following code on a jsp page: <jsp:useBean id="gameBean" type="FYPCode.GameBean" scope="request" /> <FORM ACTION="MatchController"> <p> <jsp:getProperty name="gameBean" property="day" /> <jsp:getProperty name="gameBean" property="dayNumber" /> <jsp:getProperty name="gameBean" property="month" /> <jsp:getProperty name="gameBean" property="year" /><br> <jsp:getProperty name="gameBean" property="homeTeam" /> vs <jsp:getProperty name="gameBean" property="awayTeam" /><br> <jsp:getProperty name="gameBean" property="venue" /> <jsp:getProperty name="gameBean" property="kickOffTime" />, kick off.<br> <b>Allocated Tickets: </b><jsp:getProperty name="gameBean" property="allocatedTickets" /> </p> <p> To choose to buy tickets for this match, click on the button below which will take you to the ground page where you can choose which stand to sit in.<br> <INPUT TYPE="SUBMIT" NAME="BuyMatch" VALUE="Buy Tickets for this match"><br> <INPUT TYPE="SUBMIT" NAME="ViewMatch" VALUE="View Stadium Plan of the match venue"> </p> </FORM> Now when I press one of the buttons it diverts to the right servlet but I am having a problem with the JavaBean in the servlet. You see I want to extract the Bean from the page and use it in the code in my servlet. Now the servlet that loads up that page is different (it's called SearchServlet) to the one that deals with the button pressing (MatchServlet). SearchServlet passes it to the page as follows: GameBean gameBean = (GameBean) matches.get(0); request.setAttribute("gameBean", gameBean); address = "/match.jsp"; RequestDispatcher dispatcher = request.getRequestDispatcher(address); dispatcher.forward(request, response); Now in the MatchServlet servlet I have tried extracting the Bean using the code: GameBean gb = (GameBean) request.getAttribute("gameBean"); But it is coming back as a null pointer error. I've also tried getting it using this code: HttpSession session = request.getSession(true); GameBean gb = (GameBean) session.getAttribute("gameBean"); But again I'm getting a null pointer error. Can anyone help me and tell me how I can extract the gameBean from the page? Many thanks Mark Whitby [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]