• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Need help in j_security_check based authentication

 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using form based authentication for accessing certain protected resource. This is what I have specified in web.xml for j_security_check



There is a link in my home page from where a user can download pdfs. If user is not logged in, login.jsp page opens where user enters his credentials and if login is successfull (data access by jdbc realm), requested pdf gets open.

URL which actually forward to login.jsp is:

http://localhost/contextName/pdfs/xyz.pdf

In login.jsp page, I want this pdfs url pattern i.e., /pdfs/xyz.pdf. Can I get that? I tried by request.getRequestURI(), but this gives me /login/login.jsp

Since there is a forward, that's why I am getting /login/login.jsp. Can I get back uri of the link which forward to login.jsp i.e., /pdfs/xyz.pdf

I hope problem is now clear to everybody

Thanks and Regards
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will always get Login page uri.

If you use filter with this scenario then you can get original uri.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

In case you haven't found a solution for your problem then here is one. I needed this very information not long ago and found that the original servlet path can be retrieved from the ServletRequest's parameter "javax.servlet.forward.servlet_path".

Edit: Note, this parameter name works in Tomcat, if you are using a different container then the path can be saved in a different way.
[ February 27, 2007: Message edited by: Mika Leino ]
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mika,


Thanks for your reply. I did something like this to retrieve the pdf_uri.

 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic