Url minus query string in Objective-C

Since iOS 8/OS X 10.9, there is an easier way to do this with NSURLComponents. NSURL *url = [NSURL URLWithString:@”http://hostname.com/path?key=value”]; NSURLComponents *urlComponents = [[NSURLComponents alloc] initWithURL:url resolvingAgainstBaseURL:NO]; urlComponents.query = nil; // Strip out query parameters. NSLog(@”Result: %@”, urlComponents.string); // Should print http://hostname.com/path

How to get base URL of an MVC application using javascript

You should avoid doing such detection in JavaScript and instead pass the value from the .NET code. You will always risk running into problems with urls like http://server/MyApp/MyApp/action where you cannot know which is the name of a controller and which the path to the application. In your Layout.cshtml file (or wherever you need it) … Read more

Is there any way to get the file extension from a URL

It is weird, but it works: string url = @”http://example.com/file.jpg”; string ext = System.IO.Path.GetExtension(url); MessageBox.Show(this, ext); but as crono remarked below, it will not work with parameters: string url = @”http://example.com/file.jpg?par=x”; string ext = System.IO.Path.GetExtension(url); MessageBox.Show(this, ext); result: “.jpg?par=x”

how to get the base url from jsp request object?

So, you want the base URL? You can get it in a servlet as follows: String url = request.getRequestURL().toString(); String baseURL = url.substring(0, url.length() – request.getRequestURI().length()) + request.getContextPath() + “/”; // … Or in a JSP, as <base>, with little help of JSTL: <%@taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %> <%@taglib prefix=”fn” uri=”http://java.sun.com/jsp/jstl/functions” %> <c:set var=”req” value=”${pageContext.request}” /> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)