aspose file tools*
The moose likes JSP and the fly likes Using a hidden field to store the url in jstl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using a hidden field to store the url in jstl" Watch "Using a hidden field to store the url in jstl" New topic
Author

Using a hidden field to store the url in jstl

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477


Hi folks,
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.

Learning and Learning!-- Java all the way!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61656
    
  67

Why aren't you using the session for this?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Bear ,
Thank you for your suggestion. But how do I go about putting the URL in to the session in that case?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61656
    
  67

Again, why not just have the filter store the URL (don't forget any request parameters that need to be recreated) in the session?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

Perhaps it's not all that obvious... store the URL in the session before you redirect to the login page.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

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 . ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61656
    
  67

Carefully examine the logic of your method. Is the code in all the right places?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi,
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 .?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61656
    
  67

Where is it you want to be able to retrieve the value? Have you checked that you are setting the value in the right place?

(Hint: the answer is no.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using a hidden field to store the url in jstl