I have to make a navigator menu for a web application (based these: java, tomcat, jsp, oracle db) that will be present in everything once the user is logged in. The point is that almost every person connected, has different privileges so each person would see a diferent navigator menu. This is one of my first web developments so I’m not very strong on the concepts of how things are communicated from the client to the server and vice-versa and therefore, what is the best to do, however some of my considerations have their pros and cons.
- Making a filter to load the menu in every request. This would query the database which is painful to it because in few cases, things are going to change (or at least, not very often); however, when there is a change, it would load immediately.
- Making an iframe to load the menu once and control the second iframe from this one (i think this is the most discouraged, but is still an option and has the advantage of not making the same request to the server everytime you click something). When there is a change, reloading would load the new data.
- Making the menu to stay as an object in the session. This will query the db once the user logs in. Changes will be loaded in every connection (or by making a button to reload). But this approach would put things in the server memory which I think is one of the worse ideas. (not sure about what I say here, I’m I wrong?)
As I said, I’m too new to this so I don’t know about anything else I can do. For what I know, I can’t write a file to the client (xml for example) so it is the data source for the menu and delete it daily or so. I can write a file in the server with the data so I don’t need to query from the db (but still this is a request to the server), but this brings other problems, changes of data would not be refreshed (unless of course, I make something to it which require more time and more things to mantain) and I don’t know if this would be faster than just accessing the db.
How are this things best implemented? consider the cost of development, mantainance, performance (reducing requests of the same information on every click), user perceived lag and others that my maturity on this subject don’t see yet. Any recommendations on books about web design?
Edit:
I’m planning to use jsTree for the visualization and making the menu sublevels to load on ajax requests.
I would forget about the second option and go with the simplest, stateless option: the first one. Databases are fast!
If it appears that this takes too much time or puts too much load on the database (but I doubt it: loading the provileges of a user should be very fast), you could always go with the third option. Sure it would store the menu (or just the privileges) in the session, but the session can also be written to the disk or the database if necessary.
Don’t pre-optimize.