Question about using JSP's with Servlets

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Question about using JSP's with Servlets

  1. #1
    Dylan Guest

    Question about using JSP's with Servlets

    I'm trying to create a bean in my servlet, store it in a request variable,
    then have a JSP page access it by using request.getAttribute. However, it
    doesn't seem to work. Can anyone tell me why. I just want to pass a bean
    from a servlet to a JSP.

    Here's the bulk of the code...

    In the servlet I'm stating -
    GreetingBean msg = new GreetingBean();
    msg.setMsg("Hello World!");

    Then in the JSP page -
    GreetingBean msg = (GreetingBean)request.getAttribute("message");

    Problem is msg.getMsg() is ALWAYS returning NULL. WHy would this be happening?

    I've also tried in the JSP page:
    <jsp:useBean scope="request" id="greeting" class="GreetingBean">

    This also returns NULL, i.e. resets the value I put in the bean on the previous
    page (servlet) which then forwards to the JSP page.

    Any ideas or tips?

    Thanks again,

  2. #2
    MarkN Guest

    Re: Question about using JSP's with Servlets

    Are you sure that it is the getMsg() that is null or is it the msg object?
    What is you error? What does your class code look like?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center