This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes conditional redirect Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "conditional redirect" Watch "conditional redirect" New topic
Author

conditional redirect

Shawn Kuenzler
Ranch Hand

Joined: Apr 16, 2006
Posts: 73
I need to redirect my JSP based on whether the the parent window has a certain name. I wrote up a simple JSP with javascript to do what I want. It doesn't work but you get the idea for what I'm looking for. Anyone care to share the best way to do this? Or help me fix whatever its doing wrong here? Thanks!



(Notice "onLoad" is spelled incorrectly because javaranch won't allow me to post with that syntax in my own code.)


SCJP 1.5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

response.sendRedirect() is not JavaScript, it's Java. You can't mix server-side Java with client-side JavaScript.

Do the redirect using JavaScript.
[ July 03, 2007: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

P.S. Using the "javascript:" prefix in your onload attribute will get you into trouble with most browsers. Remove it as unnecessary.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: conditional redirect
 
Similar Threads
RequestDispatcher.forward not working
How can i use message window in servlet
JavaScript page load get value of anchor
Redirect to a page in portlet doView
problem using greybox