2 Replies Latest reply on Feb 26, 2005 3:44 AM by Puneet Jain

    Database access from the web tier

    Sriram A Newbie


      I'm involved in the development of J2EE web application using an 'standard' architecture.
      View layer - Struts
      Business layer - Session EJB
      Persistence layer - Hibernate

      We found that in few screens, where a drop-down needs to be populated based on a particular status selected by the user, the response time is slower beacuse the request has to fow through struts and then to the busniess layer and then fetch the result (contents for the drop-down).
      We were considering the option of having a helper bean that we can use on the web tier to directly access a table and return the contents for populating the drop-down (and hence avoiding the round trip through struts-session EJB-hibernate.

      Please tell me is it a good design practice to access the database through web-tier?.

      My client says it is a bad practice to access database (through java bean) from the web tier.

      Appreciate your inputs on this.


        • 1. Re: Database access from the web tier
          jamesstrachan Newbie


          See also my response to your other query.

          Direct access from the web tier is probably undesirable because it breaks the model and will probably make it difficult to generate ther correct HTML within Struts.

          A better solution is to introduce an application server tier and to store the variable drop-down data within Entity beans.

          It is most efficient if all entries for a drop down are stored as a set of Strings (or other objects) within a single Entity bean. This should be possible with Hibernate.

          After the first access to a drop down, subsequent accessses should read directly and quickly from the Entity Bean.

          As a second thought, you may want to check that the current database read is efficient and is not performing a table scan.

          James Strachan

          • 2. Re: Database access from the web tier
            Puneet Jain Newbie


            Have u looked at google suggests
            It uses a kind of XMLHttpRequest i.e call your server side code from