Please help for the below requirement.

I have a web portal and when I open that URL it redirects to different URL ( login page)
I am able to capture the redirected URL using java code. But How I will submit that redirected URL with user name and password to check the login is success or fail using java code.

SO Please help me how to submit the redirected URL with parameters.