It's not a secret anymore!*
The moose likes Servlets and the fly likes Trying to use the OpenConnection() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Trying to use the OpenConnection()" Watch "Trying to use the OpenConnection()" New topic

Trying to use the OpenConnection()

von rodrig

Joined: Jun 28, 2002
Posts: 2
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

Joined: Jun 13, 2002
Posts: 13
Use an HttpURLConnection and call the getResponseCode().
You can do something like this:

I agree. Here's the link:
subject: Trying to use the OpenConnection()
Similar Threads
JSF : redirect errors to error page
How to avoid using session scope in this case?
importing error in JSP
displaytag library, add/append parameters (from Httpsession) to Page number links
JSP HTTP Status 404 The requested resource (/*.jsp) is not available