Off-line optimal planning of trajectories for redundant robots along prescribed task space paths is usually broken down into two consecutive processes: first, the task space path is inverted to obtain a joint-space path, then, the latter is parametrized with a time law. If the two processes are separated, they cannot optimize the same objective function, ultimately providing sub-optimal results. In this paper, a unified approach is presented where dynamic programming is the underlying optimization technique. Its flexibility allows accommodating arbitrary constraints and objective functions, thus providing a generic framework for optimal planning of real systems. To demonstrate its applicability to a real world scenario, the framework is instantiated for time-optimality. Compared to numerical solvers, the proposed methodology provides visibility of the underlying resolution process, allowing for further analyses beyond the computation of the optimal trajectory. The effectiveness of the framework is demonstrated on a real 7-degrees-of-freedom serial chain. The issues associated with the execution of optimal trajectories on a real controller are also discussed and addressed. The experiments show that the proposed framework is able to effectively exploit kinematic redundancy to optimize the performance index defined at planning level and generate feasible trajectories that can be executed on real hardware with satisfactory results.