Separate business from presentation

Discussion in 'Java' started by Sboffo, Oct 20, 2003.

  1. Sboffo

    Sboffo Guest

    It is a good practise to build servlet for business (DB access)
    and servlet for presentation (HTML).

    Logically it is light, but the problem is to send data from
    the first to the second, in particular way when data is big.

    If I get a lot of data from DB, how can I send them to the
    presentation servlet?

    My solutions are:
    -using session (quick to build, but slow to execute)
    -using XML (slow to build, and maybe slow to execute)
    -using array of object (slow to execute: the add method
    is slow).

    How do you thing to be the best?
    Why?

    Thank you very much.
    Ferro.
     
    Sboffo, Oct 20, 2003
    #1
    1. Advertising

  2. "Sboffo" <> wrote in message
    news:bn1hj3$hv1$...
    > It is a good practise to build servlet for business (DB access)
    > and servlet for presentation (HTML).


    The good practice is to have the servlet delegate the business logic to some
    helper classes (if not using EJBs) and the presentation to a JSP.

    >
    > Logically it is light, but the problem is to send data from
    > the first to the second, in particular way when data is big.
    >
    > If I get a lot of data from DB, how can I send them to the
    > presentation servlet?


    The data (Model) is normally passed by the servlet (Controller) to the JSP
    (View) as attributes to the request object.
    From separation of responsibilities perspective the data should be in the
    form of Java Beans, so the person writting the JSP is not required to
    understand java at all (he knows how to use its HTML editor that happens to
    know about Java Beans specification).

    >
    > My solutions are:
    > -using session (quick to build, but slow to execute)

    No, someone has to clean up after that. That is why in the request - it will
    be thrown away.

    > -using XML (slow to build, and maybe slow to execute)

    No, XML is too slow and therefore recommended for data exchange between
    applications (written in different language by different vendors and so on),
    but not between the Controller and View in the same program. If someone
    tells you the opposite - that is just a buzz word.

    > -using array of object (slow to execute: the add method is slow).

    ???

    Regards,
    Dobromir
     
    Dobromir Gaydarov, Oct 21, 2003
    #2
    1. Advertising

  3. Sboffo

    Ferro Guest

    > The data (Model) is normally passed by the servlet (Controller) to the JSP
    > (View) as attributes to the request object.


    But some times I need to pass a lot of data: 200-300 record with 10 fileds
    everyone.
    Is it more efficient REQUEST or XML?
    Remember that servlet has to:
    -READ many data from DB
    -WRITE many data to request
    and JSP has to:
    -READ many data from request
    -WRITE many data to response.

    > From separation of responsibilities perspective the data should be in the
    > form of Java Beans, so the person writting the JSP is not required to
    > understand java at all (he knows how to use its HTML editor that happens

    to
    > know about Java Beans specification).


    I know JSP and servlet, but don't know JavaBean: but are JavaBean more
    elegant or more quick than request?

    [OT]: Can I mean JavaBean as Servlet client side?

    > > -using array of object (slow to execute: the add method is slow).

    > ???


    Class pippo{
    public int field1;
    ...
    public int fieldN;
    }

    pippo data_from_servlet_to_jsp = new pippo[];

    Do you understand?

    Ciao, Ferro.
     
    Ferro, Oct 21, 2003
    #3
  4. Ferro wrote:

    >> The data (Model) is normally passed by the servlet (Controller) to the
    >> JSP (View) as attributes to the request object.

    >
    > But some times I need to pass a lot of data: 200-300 record with 10 fileds
    > everyone.
    > Is it more efficient REQUEST or XML?
    > Remember that servlet has to:
    > -READ many data from DB
    > -WRITE many data to request
    > and JSP has to:
    > -READ many data from request
    > -WRITE many data to response.


    That's not that much data, and putting the data in the request is not slow.
    Have you actually tried it, and benchmarked it? Or are you just assuming it
    is slow?

    >
    >> From separation of responsibilities perspective the data should be in the
    >> form of Java Beans, so the person writting the JSP is not required to
    >> understand java at all (he knows how to use its HTML editor that happens

    > to
    >> know about Java Beans specification).

    >
    > I know JSP and servlet, but don't know JavaBean: but are JavaBean more
    > elegant or more quick than request?
    >
    > [OT]: Can I mean JavaBean as Servlet client side?
    >
    >> > -using array of object (slow to execute: the add method is slow).

    >> ???

    >
    > Class pippo{
    > public int field1;
    > ...
    > public int fieldN;
    > }
    >
    > pippo data_from_servlet_to_jsp = new pippo[];
    >
    > Do you understand?
    >
    > Ciao, Ferro.


    --
    Regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Oct 21, 2003
    #4
  5. Sboffo

    Ferro Guest

    > That's not that much data, and putting the data in the request is not
    slow.

    Do you think so when 250 users run on server?
    Maybe they aren't concurrent, but maybe 100 users can be!

    > Have you actually tried it, and benchmarked it? Or are you just assuming

    it
    > is slow?


    :))))))
    I try to understand the problem.
    I will do it.
    But to do it, having some thought about it, is different.

    Thank you.
    Ferro.
     
    Ferro, Oct 21, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Learner
    Replies:
    5
    Views:
    645
    Karl Seguin
    Dec 21, 2005
  2. dan
    Replies:
    25
    Views:
    1,341
    Uncle Bob (Robert C. Martin)
    Oct 28, 2003
  3. Universe
    Replies:
    1
    Views:
    479
    Universe
    Oct 24, 2003
  4. EvgueniB
    Replies:
    1
    Views:
    648
    Anthony Borla
    Dec 15, 2003
  5. Dhananjay
    Replies:
    1
    Views:
    1,132
    sloan
    Dec 18, 2006
Loading...

Share This Page