I'm building a web application, where a user can send a HTTP request to upload a file. I need to redirect the user to the login page in my servlet and if the authentication is successful, I need to process the request. What's the best option to do this? Here's what I'm thinking of doing:
- Save the request URL and the HTTPServletRequest object in a cache(some in-memory cache like JCS) with a specific request ID(some GUID).
- Redirect the user to the login page along with the request ID.
- When the user logs in, the request id is also passed to the servlet.
- If the login is successful, retrieve the HTTPServletRequest object from the cache and start processing it.
Another option I read about was using the HTTPReferrer, but this wouldn't get me the request parameters(it is a post operation).
Is my approach above right? Is there a better way to handle this?
Thanks in advance!