Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

any java code for - window.location.href

 
dp sharma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a scenario, where I currently on the page (say: www.abc.com/forummodules/2010/abc/index.html) and then I click a url (say: www.abc.com/forummodules/2010/report.html?param1=xyz) and if the user is not logged in then he/she is redirected to login page (say: www.abc.com/forummodules/login) before being directed to actual url.

Now the in address bar it shows url: www.abc.com/forummodules/2010/report.html?param1=xyz but I am on login page actually.

I want that address in the url i.e www.abc.com/forummodules/2010/report.html?param1=xyz
when I do request.getRequestedURL() I get www.abc.com/forummodules/login?param1=xyz

doing javascript i can get that required address (using: window.location.href) but is there any way in java to achieve this

Thanks in advance

- dp
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have the page you don't want do a redirect to the page you do.
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does request.getRequestURI() give you more accurate information? Strait from the javadoc, "The web container does not decode this String."
 
dp sharma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pete,
This doesn't works.. It gives same Login page url.

Hi Jeanne,
Can you please describe it in more detail..

Thanks
- dp
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dp sharma wrote:Hi Jeanne,
Can you please describe it in more detail..

And without a typo that confuses matters ? Sure.

In MVC, you normally forward to a JSP. A servlet also lets you redirect to another URL. I was thinking you could forward from the URL you don't want to the one you do. Although now that I think about it more, I don't remember if a redirect actually changes the URL in the browser. I know if you press F5 (refresh), it submits to the second URL. I just don't recall what shows in the address bar.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64632
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A redirect will cause the browser's address bar to change.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:A redirect will cause the browser's address bar to change.

Thank you. Turns out I pay much more attention to the behavior than the URL. It's good to know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic