Submit web site - 130 CHAPTER 5 PERMUTATIONS PATTERN Implementing the

130 CHAPTER 5 PERMUTATIONS PATTERN Implementing the Details of URL Rewriting Looking a bit closer at the wiring of the IURLRewriter and IRewriter interface instances, you can see that some details were not explained in the OnBeginRequest function. These details indicate the logic of how to convert a resource into a representation and are described as follows: 1. Verify that the URL is referring to a resource. 2. If the URL is a resource, process the URL. Otherwise, ignore the URL and let the HTTP server process the request. 3. Read the Accept HTTP headers from the request and store them in an array. 4. Sort the array so that the highest-priority Accept header is at the beginning of the list. 5. Iterate the array and attempt to rewrite the URL for each item. 6. If during the looping the URL could be rewritten, exit the loop and let the other filters continue their processing. The class RouterASPNet is responsible for steps 1, 2, 3, and 5. Step 4 is delegated to another yet-to-be-described class, and step 6 is implemented by DefaultRewriter. The implementation of URLRewriterASPNet is defined as follows: class URLRewriterASPNet : IURLRewriter { E B V N IRewriter _defaultRewriter; public URLRewriterASPNet( IRewriter rewriter) if (_defaultRewriter == null) throw new Exception( “Rewriter cannot be null”); } _defaultRewriter = rewriter; } public bool IsResource(HttpRequest request) FileAttributes attributes; try attributes = File.GetAttributes(request.PhysicalPath); } catch (FileNotFoundException ex) { return false; } if ((attributes & FileAttributes.Directory) != 0) { return true; else return false;
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply