Is it good to put this ../../ in the code? or what approach should I take?
sure or alternatively use JSTL to create URL's which will prefix the context root.
for example if welcome is right off your context root, it might look something like below:
On a side note if I understand what I think your doing you are reinventing the wheel.
You should take a look at spring-security for this sort of thing.