emre akbas wrote:
Hi,
I want to implement a "secure file server" using Struts. By "secure" I mean,
when a file is requested by a user, a "checkAccess" method will be called
and it would check if the user has right to access that file (datasource
will be used for this check) If checkAccess return true the file will be
sent to the user. This scenario is very well suited to the logic of
DownloadAction BUT my fileserver has to work with html files containing
images. When you request an html file containing images, the browser will
automatically request that images from the server. For this to work i should
pass the filename in a regular URL like in "
http://localhost:8080/myfileserver/try.html" . I think this has to be like
this, I cannot pass the filename as a request parameter like in "
http://localhost:8080/myfileserver?filename=try.html" since this way images
will not be requested properly.
My problem is I cannot construct an url mapping in web.xml such that when
user clicks this link: "http://localhost:8080/myfileserver.do/try.html" I
should be able to obtain the "try.html" part. But the default Struts action
servlet mapping which is "*.do" does not allow this. I tried "*.do/*" but no
way.
How can I find a mapping such that request.getPathInfo() would not return
"null" for me.
Thanks in advance.
To do that you'll need to use URL prefix mapping instead of suffix
mapping. Suffix mapping can only match the tail end of the URL (hence
the name!).
If you map action servlet to /do/* instead of *.do, you can access your
action as 'http://localhost:8080/do/myfileserver'. From there, you can
use wild-card action paths to match the path extra info:
<action path="/myfileserver/**" ...
Your action can then get the remainder of the URL and serve the request
as normal. The User Guide has more details of using wild-card mapping
paths [1].
HTH,
L.
[1]
http://struts.apache.org/userGuide/building_controller.html#action_mapping_wildcards
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]