• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How do I redirect to a specific URL?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running a Java application using Tomcat 6 and JBoss 5.1. I've created an URL redirection function using Java Elements addHtml() function (javascript). Well, I am able to alert the URL of current browser (alert(window.location.href)) but I am not able to redirect to a specific URL (window.location.href = 'URL'). The code shown as below:



At the same time, the IE status bar is processing http://www.google.com but somehow it does not redirect me to the page. Help needed. Thanks in advance =)
 
Sheriff
Posts: 67650
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "Java Elements"?
 
Joe Kang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/Element.html Here you go
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to Javaranch Joe!
 
Marshal
Posts: 27286
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Kang wrote:http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/Element.html Here you go



Okay, I'm lost. So now I understand that the code you posted is Java code. Or so you say. However the documentation you linked to is confusing, because in your code the Element object has an addHtml() method and in that documentation, it doesn't.

But anyway, what are you trying to do? If you want to redirect to some other URL from that Java code, then generating Javascript code is pointless. And generating a DOM which contains that Javascript is just as pointless. Just call the response object's sendRedirect(URL) method.

Or were you hoping the Javascript code could somehow redirect to the URL? If you somehow managed to get it into the browser, that is? You remark about IE's status bar pointing to www.google.com is also baffling because if the browser sent a request to that URL then your code wouldn't be running.

So I would suggest you go back a couple of steps and try to explain all of this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic