IBM WCS V 7.0 (Madison & Elite) starter store acts like this as OOTB . (I am not sure about WCS V 6.0) ,but below are the concept :
you need to add
authenticate
property for your developed/customized view instruts-config-ext.xml
as 1 , so this view can only be accessed by registered userswhen guest user tried to access that page/View , WCS framework will automatically redirect him to login page view asking user to login
OOTB login page view JSP content is
AccountDisplayContent.jspf
the form of the login contiains hidden input with name : "URL" like below:<input type="hidden" name="URL" value="<c:out value='${WCParam.URL}'/>" id="WC_AccountDisplay_FormInput_URL_In_Logon_1" />
actually there are logic in the JSP for different possibilities of what URL can be , but one of them is the previous URL page that struts actions framework will fill it for you and become hidden input .
this field is been read in OOTB
LogonCmdImpl
(if you haven't customize it) and after authentication process succeed , this command read that field and redirect you to view that you come from to login page .same process for registration (as long as you use one page for registration , not multiple pages/flows that could make this field lose its value .
Hope that help you look at your code and review what is missing .
Thanks