Im trying to store the url of the previous page in a hidden field , so that I may access it after authentication , in the eventuality of a user trying to access a secure web page . Any clue on how I would go about retreiving the url of the previous page using jstl would be appreciated.
Thanks for the reply Paul !But , where exactly would I put this code? In the servlet associated with the login page , I handle the authentication in the doPost method . However, upon submitting the page I get the value of the String previousPage as in the previous example as null.
Yeah, I figured that "how do I go about putting the URL in to the session in that case?" wasn't really your question. So could you step back a bit and figure out what your actual question is? And then tell us, complete with details? One detail which is conspicuously missing is what you mean by "previous page", for example.
Well , let me explain my problem a bit more clearly,maybe you can help me figure out an alternative solution than the one I'm currently trying to implement.
My web application is currently secured through a filter, where in the filter checks if a valid user is present by examining the session and allows the user to progress through the application as long he's validated .
Now , when someone tries to access a protected page he/she is thrown off to the login page for authentication , but the problem I face currently is that post authentication the user is redirected to a common page , rather than the initial protected page that s/he had requested.
Is there a way where I can send the user to the page he initially requested rather than the common page ?
I was hoping to store the value of the page that the user had initially requested in a hidden field , which I hope validates my initial question of storing the previous url in a hidden field.
Bear Bibeault wrote:Again, why not just have the filter store the URL (don't forget any request parameters that need to be recreated) in the session?
Hi Bear and Paul,
I've tried to do something like the both of you've suggested, in my filter.
Here's what I've done in my filter common to all the secure pages
However , I hoped that I would be able to see the url of the previous page , every time I moved through a secure page , but the previous page string does not seem to print. I guess I'm missing something fundamental here . ?
Vic Hood wrote:I guess I'm missing something fundamental here
I think so. For one thing I don't see where you assign a value to the "previousPage" variable, which would explain why you're not seeing anything meaningful when you display it. I don't have any suggestions about that; I already asked you to explain what "previous page" meant and I haven't seen an explanation yet. So you should first try to produce an explanation of what it means, and then write some code to assign that to the variable. And do take note of the last suggestion I made.
Thank you for your replies .
To answer's Paul's question , by 'previousPage' i mean the url of the previous page , and as suggested by you in an earlier post below.
Paul Clapham wrote:
I try to obtain the url of the previous page and place it into the session
As for Bear's question , this is what I intend to do , I try to get the value of the previous page in the url , if the user is authenticated ,then assign it to a string of the name 'previousPage' and print it , after that I go about processing the filter request using chain.doFilter . I guess I'm missing something in between .?