aspose file tools*
The moose likes Servlets and the fly likes any java code for - window.location.href Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "any java code for - window.location.href" Watch "any java code for - window.location.href" New topic
Author

any java code for - window.location.href

dp sharma
Greenhorn

Joined: Jun 18, 2010
Posts: 3
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

You could have the page you don't want do a redirect to the page you do.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

Does request.getRequestURI() give you more accurate information? Strait from the javadoc, "The web container does not decode this String."


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
dp sharma
Greenhorn

Joined: Jun 18, 2010
Posts: 3
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

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

Joined: Jan 10, 2002
Posts: 60057
    
  65

A redirect will cause the browser's address bar to change.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any java code for - window.location.href
 
Similar Threads
URL Address
How to make selective jsp files secured
URL Redirecting in iPlanet Web Server 4.1.11
How to get the URL of the page which redirected to our site ?
Redirection