This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

go to a web url using java code  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a jsp page, and there is a button on it, when I click this button, I want to go to another url, let's say http://www.google.com. Is it possible to do it. Can one give me a clue how to implement this using Java?

I tried something like

URL link = new URL(intraURL);
HttpURLConnection httpConnect = (HttpURLConnection)link.openConnection();
httpConnect.setRequestMethod("GET");
httpConnect.setDoOutput(true);
System.out.println(httpConnect.getURL());
httpConnect.connect();

It doesn't work, I guess the above codes just makes a connection, but not physically go to the page.

any help will be apprecitaed.

thanks.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well you could make the button go to the page without posting to the servlet. But based on your code I assume you want the JSP to post to a servlet. If thats true take a look at sendRedirect method of HttpServletResponse.

Oh this probably belongs in JSP or Servlets.
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Paul Hankerg:
I have a jsp page, and there is a button on it, when I click this button, I want to go to another url, let's say http://www.google.com.



Once the page is presented to the user on the client, and hence the oppurtunity to click on the button, all the Java has already executed on the server.

So the answer to your question is:



Why do you think that any Java at all is necessary?
[ October 04, 2006: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!