Nic Ferrier wrote:
Now look at what the requests would do:Hmmm.... Assuming all valid URI's for my site pointed at servlets, and I conscientously mapped each one, that would be great. Each servlet can test the validation condition.request / invokes servlet1
request /foo invokes servlet2
request /foo/bar invokes servlet3
request /foo/bar/one invokes servlet3
But I was hoping that my servlet container would also serve up files for me (as Tomcat does, for instance), and I was hoping to just add them in the directory tree, without creating an explicit mapping for each one.
And so, some request is going to resolve all the way back to '/', the servlet will then use a RequestDispatcher to forward them onto '/somepage.html' and invoke itself again.
Now, the problem may just be that the servlet API says nothing about the servlet container serving up files, and that I should just not be so lazy, and use getNamedDispatcher from the ServletContext, and if it doesn't resolve, then dish up the file myself using ServletContext.getResourceAsStream(). But then I (might) lose any of the smarts of the servlet container dealing with non-file resources, and I will definitely not do as efficient an implementation as someone who knows what they're doing.
The request dispatcher seemed so promising....surely they though of
this scenario?
But, thinking outside the box a little (it is a box, not a square, understand...somebody once insisted that the proper expression was 'square' ;-), I would prefer not to implement the default servlet at all! I'm just trying to add some authentication stuff, after all, not invent new ways of serving up resources.
I would prefer to have some fancy implementation of my servlet container allow me to customize its form-based-login a bit further. (Tomcat may in fact get such a contribution from me if I feel this is the best solution).
That way, the container does all the work, as it properly should, and
I don't have to write a servlet that uses RequestDispatcher and map every
resource in my site by hand.
One way to do what you want might be to map the initial servlet to aHmm...resources are named differently to their URI's. Feasible, but...I dunno, it seems like a hack, as well as a management nightmare. (I like my namespaces to be consistent, I guess. If it's HTML, call it *.html, whether that's on the non-public file-system or a public URI. Bit of a purist, I suppose. Should get a life, perhaps... etc.)
file path (eg: .html) and then strip that off when you RD.forward().
Regards,
David.
-- David Bullock Project Manager - Strategic Applications [EMAIL PROTECTED]
"It's no use saying 'We are doing our best.' You have got to succeed in doing what's necessary." ...Winston Churchill LISAcorp http://www.lisa.com.au/ Adelaide Sydney -------------------- ------------------------ 38 Greenhill Rd Level 3, 228 Pitt Street Wayville S.A. 5034 Sydney NSW 2000 PH +61 8 8272 1555 PH +61 2 9283 0877 FAX +61 8 8271 1199 FAX +61 2 9283 0866 -------------------- ------------------------
