JSP, JavaBean and Servlet interaction


Web tier: servlets, JSP, Web frameworks: JSP, JavaBean and Servlet interaction

  1. JSP, JavaBean and Servlet interaction (3 messages)

    Good Day,

    I have read the Value Object Pattern presented by this site and was impressed. I was wondering if it was possible to directly post a JavaBean (Value Object) to a servlet so that the servlet can pass that JavaBean (Value Object) to the EJBSession object so that it can start processing the request.

    Basically as follows...

    <FORM method="POST" action="SomeServlet">
      <JSP:useBean id="SomeBean" class="ValueBean">
        <JSP:setProperty ....>
        <JSP:setProperty ....>

    ValueBean v = request.getParameter("....");

    //Get EJB session
    //Send EJB session object the value object


    Mark Ashworth
  2. No, as a new request is created when you submit the page you will lose all data stored in the value object.
  3. Simple POSTing is impossible if only because of what it means: client sends an HTTP request to the server. Value object is your server-side object and your client does not have the slightest idea of its content. You can post only strings - that's what TCP/IP does, and JSP-container could also take care of parsing them into primitive types behind the scene. Everything else is out of bounds. What you can do is reconstruct your value objects from string pieces.
  4. Thank you, somehow I had an idea that would be the case