Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading user URL  RSS feed

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want that when the user came to login then login servlet should remember the target URL and after verification it should redirect to the target URL from which the user came

kind regards
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, that's how servlet security works. If a user accesses a protected URL, the server redirects him/her to the login page, and after successfully logging in, redirects back to the originally requested page.

So, your starting URL should not be a login page, but the protected start page, in other words, the main menu (or whatever makes sense for your web app).
 
in Mkumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Request.getURL() method to get url and after verification and validation redirect the same url to user - Cheers Manoj
[ September 11, 2008: Message edited by: in Mkumar ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do agree with Ulf, as you need not do anything for this redirection to happen. Access to authorized pages will redirect to login page and after successful login, fall back to authenticated page user was willing to access.

Defining the authenticated resources under security constraint in web.xml and having configuring login page (if custom login page required) will do the desired favor.
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chandra Bhatt:
I do agree with Ulf, as you need not do anything for this redirection to happen. Access to authorized pages will redirect to login page and after successful login, fall back to authenticated page user was willing to access.

Defining the authenticated resources under security constraint in web.xml and having configuring login page (if custom login page required) will do the desired favor.


Can you please quote any example web.xml that deals this scenario?

Kind regards
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by in Mkumar:
You can use Request.getURL() method to get url and after verification and validation redirect the same url to user - Cheers Manoj

[ September 11, 2008: Message edited by: in Mkumar ]


Dear Kumar,
Its not work with me, may be it need some package to import.

best regards
 
Sanjay Madhu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still not clear regarding your requirements.
I would suggest, You need to clear about functionality and responsibilty of Servlet.

You can retrieve Request information using,
request.getRequestURL();
or.
request.getRequestURI();

Now for it depends on how you want to send response.
response.Redirect("http://www.google.com");
or
request.getRequestDispatcher("test.jsp").forward(request, response);


I hope you got your answer.

Sanjay
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks, please take the time to read what is being asked, and if you're not familiar with servlet security -which is what the question is about- try not to confuse the issue by suggesting that the wheel be reinvented.

Servlet security does the redirecting automatically. There's no need whatsoever to do that in your servlet code. There's an extensive introduction available here.
 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Folks, please take the time to read what is being asked, and if you're not familiar with servlet security -which is what the question is about- try not to confuse the issue by suggesting that the wheel be reinvented.

Servlet security does the redirecting automatically. There's no need whatsoever to do that in your servlet code. There's an extensive introduction available here.


Great!

I think that's what I was looking for

thanks a lot
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!