From: James Britt Date: 2004-09-14T02:33:57+09:00 Subject: Re: [webrick] How to extract filename from a request? Daniel V�lkerts wrote: > > This is my flow > > Browser is pointed to http://localhost/filter/filter1.fd > > As my Servlet ist mounted to /filter he regonize the request and thats > the part I'd like to implement -> now the servlet should look up the > filter to use (here filter1.fd) and should parse this filter file for > directives which controll the output. So, the part of the URL that comes after /filter/ is data to be passed to some method? > > So I've to extract the filename from the request_uri. The way I went > today is to call > > filterName = req.request_uri.to_s.scan(/\w+\.fd/) > > My question was if there is another possible better ruby way or variable > included with webrick to accomplish this task. If you have /filter/ mapped to a servlet, and call http://localhost/filter/someFilterFile, then, in your servlet, request.path should give you "/filter/someFilterFile" def do_GET(req, res) url_parts = req.path.split( '/' ) base = url_parts[0] filter_file_path = url_parts[1] end That's one way to grab the data. (Not the best; no error checking, etc.) James