Tomcat started in Eclipse but unable to connect to http://localhost:8085/

What are you expecting? The default Tomcat homepage? If so, you’ll need to configure Eclipse to take control over from Tomcat. Doubleclick the Tomcat server entry in the Servers tab, you’ll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation. This way Eclipse will take full control over Tomcat, … Read more

Easy way to test a URL for 404 in PHP?

If you are using PHP’s curl bindings, you can check the error code using curl_getinfo as such: $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); /* Get the HTML or whatever is linked in $url. */ $response = curl_exec($handle); /* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if($httpCode == 404) { /* Handle … Read more

How to redirect to a 404 in Rails?

Don’t render 404 yourself, there’s no reason to; Rails has this functionality built in already. If you want to show a 404 page, create a render_404 method (or not_found as I called it) in ApplicationController like this: def not_found raise ActionController::RoutingError.new(‘Not Found’) end Rails also handles AbstractController::ActionNotFound, and ActiveRecord::RecordNotFound the same way. This does two … Read more

How can I properly handle 404 in ASP.NET MVC?

The code is taken from http://blogs.microsoft.co.il/blogs/shay/archive/2009/03/06/real-world-error-hadnling-in-asp-net-mvc-rc2.aspx and works in ASP.net MVC 1.0 as well Here’s how I handle http exceptions: protected void Application_Error(object sender, EventArgs e) { Exception exception = Server.GetLastError(); // Log the exception. ILogger logger = Container.Resolve<ILogger>(); logger.Error(exception); Response.Clear(); HttpException httpException = exception as HttpException; RouteData routeData = new RouteData(); routeData.Values.Add(“controller”, “Error”); if … Read more

Servlet returns “HTTP Status 404 The requested resource (/servlet) is not available”

Introduction This can have a lot of causes which are broken down in following sections: Put servlet class in a package Set servlet URL in url-pattern @WebServlet works only on Servlet 3.0 or newer javax.servlet.* doesn’t work anymore in Servlet 5.0 or newer Make sure compiled *.class file is present in built WAR Test the … Read more