This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to use the OpenConnection()

 
von rodrig
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a servlet that will check to see if an url exist and if exist display the page if it does not exist display an error message. Also, if the page give a 404 error code they need to be redirected. How do I do this? Need help!!!
 
Bonnie Beach-Morin
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use an HttpURLConnection and call the getResponseCode().
You can do something like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic