Results 1 to 5 of 5
  1. #1
    lisa.lipsky is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default JSP functions and Java Bean methods

    Hi all,

    I'm new to jsp and I have a question that I couldn't find an explanation for.
    I want to know why most functions are written inside Java Beans instead of JSP pages.
    I know this may sound like a silly question but if I can have clarification to my confusion, I'm entirely grateful.

    Regards,
    Lisa

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    JSP should be primarily used for the presentation purpose. We should avoid writing our business logic, data access logic etc. inside jsp pages, rather we should put them in java classes. Moreover if you look on this also makes our code modular. If you have to make any changes in business logic or data access logic you dont need to do any thing in the jsp page, and on the contrary if you have to make some changes in the presentation part you will just make changes in the jsp page, you dont have to do any thing with the java classes.

  3. #3
    lisa.lipsky is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    What if I write the inside one jsp, for example logic.jsp and has all my other jsp pages include logic.jsp? Is this advisable?

  4. #4
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    6

    Default

    No. Because as per MVC-II what you mostly follow in web application these days, three different things had different usage. Model->Bean classes,other helper classes
    View->output what the user gets (Generated through jsp) and controller->Servlet.

  5. #5
    lisa.lipsky is offline Member
    Join Date
    Jul 2009
    Posts
    8
    Rep Power
    0

    Default

    OK. Now I know why most business logics are written in Bean. Thanks.

Similar Threads

  1. Calling java functions from c++
    By khajalid in forum New To Java
    Replies: 13
    Last Post: 10-12-2010, 11:50 PM
  2. stateless session bean with methods
    By mihael in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-15-2009, 09:55 PM
  3. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 02:34 PM
  4. java copy paste cut and undo functions
    By Mr tuition in forum AWT / Swing
    Replies: 1
    Last Post: 12-09-2007, 01:02 AM
  5. Replies: 0
    Last Post: 09-26-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •