There's nothing illegal about the occupation per se, although it is clearly a bad situation for the local population.
As far as the current conflict is concerned, Israel is one of the more moral armies around. It is fighting against Hamas, which houses weapon stores among densely-populated civilian areas and builds tunnels under civilian areas to launch terror attacks, leaving Israel no choice but to fight among urban populations. As if that were not enough - Hamas tells its own people to ignore Israel's warnings to leave town, because they know that civilians are their best defence. As opposed to occupying, using human shields is actually a crime under international law. See http://www.icrc.org/customary-ihl/eng/docs/v1_cha_chapter32_..., for instance.