TAGS :Viewed: 2 - Published at: a few seconds ago

[ structure of an application with servlets, jsp and database ]

I have just started to learn how servlets and jsp works but I am afraid I need a bit help.

The application I am writing mainly is going to consist of a page that displays a list of people together with courses they took. If one clicks on a course entry, a text field will open up where an evaluation can be inserted. example for the list:

  • group1
    • anne
      • modern dance
      • html & css
    • henry
      • mountain biking
      • sailing
  • group2
    • kate
      • html & css
      • preparing sushi
    • ...

In my database there are tables as well for the people as for the courses, groups and the evaluations.

My main problem is now to find out the database ids of a course, evaluation and person when somebody clicks on a course entry.

I think I have to store the ids somewhere in the jsp when setting up the list, but: where?

-> In the html like <li id="1"...> ? Is it a security problem that one could see all the ids when looking at the source code of the page? The reports have to be protected against unauthorized changes..

-> Does a Bean make more sense?

-> Some interesting construct I don't know yet?

And what prevents me from havint to make the ids visible in the GET call to the servlet?

Which is an elegant way to get this data to my servlet where my database queries are handled? (I think it is a good idea to have a servlet as Controller and the jsps as Views in a MVC pattern?!)

As you see I am not quite sure how to structure my application. Can you help me to get a better overview?

Thank you very much in advance! :)

Answer 1

For your question about the storage of the Ids on the JSP, I think it's a bad idea. Beans are better to do that, you can easily create the lists you want using jstl and lists of objects created with beans. It will look like:

<c:forEach var="grp"  items="${Group}">

                      <c:forEach var="pers"  items="${Person}">


There are a lot of methods for doing what you want.

An MVC pattern is a real good idea. You can use a frameworks like Spring MVC for the Model and View with Hibernate JPA for the Data Access Object layer. These frameworks manages the configurations and the integrations of all entities ans there are a lot of good tutos to learn them.

You can also use Ajax for getting the datas, but it doesn't respect the Object-oriented programming.