You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Michael Q. Ma" <mi...@soprano.com.au> on 2001/07/30 06:58:44 UTC
How to get request EXTRA PATH INFO?
RE: tricky mappingI have met the same problem that I want to extract the extra path info from the request, instead of query string. What Mr. McClanahan said in his email doesn't seem to be very correct since I have tried but failed:
Mr. McClanahan said:
======================================================================
* Map the Struts controller servlet to a path
pattern ("/execute/*") instead of an extension ("*.do").
* This means that a typical action request might
be something like "/execute/showAttachment" instead
of "/showAttachment.do".
* Now, path mappings let you do something that
extension mappings don't -- you can add "extra path"
information after the part that selects the action,
so you can say something like:
"/execute/showAttachment/1.txt"
and your "/showAttachment" action will still get
executed.
* When the user goes to save this request, the default
filename will be "1.txt".
======================================================================
It seems that the struts 1.0 won't treat /1.txt of "/execute/showAttachment/1.txt" URI as extra
path info, but try to match "/showAttachment/1.txt" with a Action class, obviously failed. So always
complains about 'Invalid path requested'.
Has somebody else have got the same problem and a solution for it?
Michael
----- Original Message -----
From: Michael Q. Ma
To: Ma Qiang
Sent: Monday, July 30, 2001 2:38 PM
Subject: RE tricky mapping.htm
struts-user
<-- Chronological --> Find <-- Thread -->
RE: tricky mapping
--------------------------------------------------------------------------------
a.. From: Craig R. McClanahan
b.. Subject: RE: tricky mapping
c.. Date: Fri, 01 Jun 2001 21:57:46 -0700
--------------------------------------------------------------------------------
On Thu, 24 May 2001, John Schroeder wrote:
> Yuri,
>
> I have run into something similar with Excel files, but I'm not sure if it
> will address your current issue.
>
> My problem: when users run a report, return to them an Excel worksheet
> instead of HTML.
> Our particular approach used JSP's to easily handle the formatting of the
> Excel doc, but you by no means would need to do so. You just need to set
> the proper Content-type and Content-disposition headers.
>
> <%@page contentType="application/vnd.ms-excel"%>
> <% response.setHeader("Content-disposition", "inline;
> filename\"myreport.xls\""); %>
>
> Now when a user chooses to save the file, the default name is myreport.xls,
> and the content returned is of the proper MIME-type.
>
> Hope this helps!
>
> --John
>
Like John, I've used the Content-disposition header for some cases like
this -- as long as the browser pays attention, it works like a charm.
For browsers that don't work correctly with it, though, there's still a
strategy for getting the effect Yuriy was after (the prompted filename is
the right thing). It goes like this:
* Map the Struts controller servlet to a path
pattern ("/execute/*") instead of an extension ("*.do").
* This means that a typical action request might
be something like "/execute/showAttachment" instead
of "/showAttachment.do".
* Now, path mappings let you do something that
extension mappings don't -- you can add "extra path"
information after the part that selects the action,
so you can say something like:
"/execute/showAttachment/1.txt"
and your "/showAttachment" action will still get
executed.
* When the user goes to save this request, the default
filename will be "1.txt".
Craig McClanahan
>
>
>
> -----Original Message-----
> From: Yuriy Zubarev [mailto:yuriy_zubarev@yahoo.ca]
> Sent: Thursday, May 24, 2001 12:33 PM
> To: struts-user@jakarta.apache.org
> Subject: tricky mapping
>
>
> Hello everyone,
>
> I'm not quite sure that my question is truly struts-related,
> but since I'm developing a web-application using struts as a framework,
> I decided to post it here.
>
> A little proem. I'm in the middle of developing a web-mail facility
> and I've come to the point where I have to display mails' attachments.
> In general everything is fine except one minor but annoying thing.
> When a user double-clicks on a attachment link and selects
> "Save target as...", a browser presents "Save as" dialog and offers
> a default name for requested object which looks like "EmailPart",
> because the syntax of the link is as following:
>
> "http://domain-name/EmailPart.do?part=1";
>
> I know the name of the requested attachment file in advance but I don't
> know how to fit it into the URL so that a browser can offer that
> name instead of "EmailPart".
>
> On yahoo web-mail a link that points to attachment looks like this:
>
> "http://yahoo_address/ym/ShowLetter/Account%5fmonitor%5fwork%5fflow.doc?box=
> Inbox&MsgId=1915_4666388_102413_741_67881_0&bodyPart=2&filename=Account%5fmo
> nitor%5fwork%5fflow.doc&download=1&YY=2060&order=down&sort=date&pos=0"
>
> Bearing in mind this syntax I tried to make my link looks like:
>
> "...domain-name/EmailPart/File_name.ext?part=1"
>
> And of course I failed, because the server (tomcat) treated
> "EmailPart" as a directory (I assume so) but not as action.
>
> So I would like to ask if anyone came across this problem
> and found a solution. Any suggestions would be highly
> appreciated.
>
>
> Thank you for your time.
>
> Best of luck,
> Yuriy Zubarev
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
>
--------------------------------------------------------------------------------
<-- Chronological --> <-- Thread -->
Reply via email to