PDA

View Full Version : webpage java redirect


tricolaire
08-21-2006, 12:35 AM
is there a way to redirect the web browser from within a java applet?

my google searches turn up nothing

TIA

Aradon
08-21-2006, 05:08 PM
My first instanct as a java programmer would be to tell you no. However java never ceases to amaze me with it's security in applets when I read this:

http://www.sightspecific.com/~mosh/Tricks/ScreenRes/


It's clunky. It's bogged down. It's an applet. Have you considered using JSP? :P

tricolaire
08-21-2006, 05:26 PM
yes, but I never learned hwo to write a JSP

Aradon
08-21-2006, 05:32 PM
I'll admit that when I first started using JSP I thought to myself. "Java? Server Side? That can't be good." But as I started to go through it I found myself liking it more and more.

Now granted it doesn't have all the ease of PHP but it's just as, if not more powerful. I'm not saying you should take your code and go completely JSP, I'm just saying it may be worth it to learn if you do more web stuff in java :)

elondon
09-21-2006, 05:19 PM
It may be a little late to post this. In case anyone needs the solution I'll post anyway.

My first instinct as a java programmer would be to tell you yes - because Java has an object for everything =p

Correct me if I'm wrong, couldnt you use the getAppletContext() method of the applet to manipulate the environment the applet runs in? I believe it also contains a showDocument() method, so for example to redirect a user to google:

getAppletContext().showDocument(new URL("http://www.google.com"));

Remember to catch the MalformedURL Exception.

I dont see how security applies here, its just redirecting the browser. You can redirect the browser virtually anywhere else as well.