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" />&nbsp;
   <jsp:getProperty name="gameBean" property="dayNumber" />&nbsp;
   <jsp:getProperty name="gameBean" property="month" />&nbsp;
   <jsp:getProperty name="gameBean" property="year" /><br>
   <jsp:getProperty name="gameBean" property="homeTeam" />&nbsp;vs&nbsp;
   <jsp:getProperty name="gameBean" property="awayTeam" /><br>
   <jsp:getProperty name="gameBean" property="venue" />&nbsp;
   <jsp:getProperty name="gameBean" property="kickOffTime" />, kick off.<br>
   <b>Allocated Tickets:&nbsp;</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]

Reply via email to