struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fzli...@omnytex.com
Subject Re: read local file in ActionStruts
Date Tue, 01 Feb 2005 18:53:52 GMT
Hmm... Could be a cache issue, although that seems kind of unlikely.  Try removing the two
cache lines in showPDF.jsp and see what happens.  Is there any chance the file isn't being
close after being written, or something along those lines?  I would also use something like
HTTPWatch and see what's actually going over the wire to and from the serve, check the headers,
all that jazz.  If I had to place a bet, I'd say it's something odd the browser is doing,
that's the case more times than not with things like this.  I know for sure I can view any
number of PDFs using this approach, and while I can't rule it out I wouldn't expect an RTF
file to present any problem.  Unlee... does the Word pluging come up to view it?  If so, that's
one more potential problem area (plugins... bleh!)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Tue, February 1, 2005 1:45 pm, gdilem\@libero\.it said:
> it works just one time.If I open another browser it opens an empty RTF
> file.My app produce correctly the RTF but your solution the second time
> does not work!
> Cache problem?!?!?
> 
> 
> ---------- Initial Header -----------
> 
>>>From      : fzlists@omnytex.com
> To          : user@struts.apache.org
> Cc          :
> Date      : Tue, 1 Feb 2005 06:46:42 -0800 (PST)
> Subject : Re: read local file in ActionStruts
> 
>> I do something like this in one app...
>>
>> I'm creating PDFs on-the-fly and then displaying them on the browser.  I
>> have a directory named temp under my webapp that the PDFs get written
>> to.  The files are named according the the user ID.
>>
>> You have the Action writing out the file already... if we assume you
>> also name it according to user ID, here's how to do it...
>>
>> (1) Make sure your Action adds the user ID to request as an attribute
>>
>> (2) Add the following forward to your ActionMapping (changing the path
>> accordingly of course):
>>
>>   <forward name="defaultForward" path="/jsp/showPDF.jsp" />
>>
>> Naturally, be sure your Action returns this forward.
>>
>> (3) Add showPDF.jsp to your webapp.  Here it is:
>>
>>   <%@ page language="java" import="java.util.*" %>
>>   <%
>>     String url = "http://";
>>     url += request.getServerName();
>>     url += ":";
>>     url += request.getServerPort();
>>     url += "/myApp/temp/";
>>     url += (String)request.getAttribute("userID");
>>     url += ".pdf";
>>   %>
>>   <html>
>>   <head>
>>     <title>Show PDF</title>
>>     <meta http-equiv="pragma" content="no-cache">
>>     <meta http-equiv="expires" content="0">
>>   </head>
>>   <body onLoad="window.location='<%=url%>';">
>>     Retrieving PDF for display...
>>   </body>
>>   </html>
>>
>> That's it.  Does the trick for me, nice and simple.
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>>
>> On Tue, February 1, 2005 9:12 am, gdilem\@libero\.it said:
>> > could u be more precise?
>> > U mean to save there the file and after that read it?!
>> > Actually I did not find any instructions.
>> > Do u?
>> >
>> >
>> > --------- Initial Header -----------
>> >
>> >>From      : DGraham@EvergreenInvestments.com
>> > To          : "Struts Users Mailing List" user@struts.apache.org
>> > Cc          :
>> > Date      : Tue, 1 Feb 2005 09:06:51 -0500
>> > Subject : Re: read local file in ActionStruts
>> >
>> >> How about using the javax.servlet.context.tempdir Servletcontext
>> >> attribute?
>> >>
>> >> Dennis
>> >>
>> >>
>> >> Keshav Shetty <Keshav.Shetty@eurodyn.com>
>> >> 02/01/2005 08:52 AM
>> >> Please respond to
>> >> "Struts Users Mailing List" <user@struts.apache.org>
>> >>
>> >>
>> >> To
>> >> Struts Users Mailing List <user@struts.apache.org>
>> >> cc
>> >>
>> >> Subject
>> >> Re: read local file in ActionStruts
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Then don't store the file within webapp, but in any server folder and
>> >> write a servlet to retrieve the file.
>> >>
>> >> Thanks & regards
>> >> Keshav K Shetty
>> >>
>> >> gdilem@libero.it wrote:
>> >>
>> >> >Tomcat  see a new created file only after shutdown and startup.
>> >> >That's a big problem.
>> >> >Help!
>> >> >
>> >> >---------- Initial Header -----------
>> >> >
>> >> >>From      : "Keshav Shetty" Keshav.Shetty@eurodyn.com
>> >> >To          : "Struts Users Mailing List" user@struts.apache.org
>> >> >Cc          :
>> >> >Date      : Tue, 01 Feb 2005 15:36:06 +0200
>> >> >Subject : Re: read local file in ActionStruts
>> >> >
>> >> >
>> >> >
>> >> >>You can store the file on sever and not in client.
>> >> >>If I understood you already created file in your struts action and
>> >> >>stored in the server.
>> >> >>So instead of giving file:// use full link with http:// link to
>> file.
>> >> >>(Hope the file is within webapp) or write your download servlet.
>> >> >>
>> >> >>Thanks & regards
>> >> >>Keshav
>> >> >>
>> >> >>gdilem@libero.it wrote:
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >>>Hi all
>> >> >>>In an Action Struts I create dynamically a file.
>> >> >>>After that whit PrintWriter I try to get the file win a script
tag
>> >> (<script>document.location='file:///xxx.xx'</script>)
>> >> >>>My problem is IE or Netscape does not allow me to read local
file.
>> >> >>>Any alternative idea?
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >
>> >> >
>> >> >
>> >> >>>
>> >> >>>____________________________________________________________
>> >> >>>6X velocizzare la tua navigazione a 56k? 6X Web Accelerator
di
>> >> Libero!
>> >> >>>Scaricalo su INTERNET GRATIS 6X http://www.libero.it
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>---------------------------------------------------------------------
>> >> >>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>>
>> >> >>>
>> >> >
>> >> >
>> >> >
>> >> >>>For additional commands, e-mail: user-help@struts.apache.org
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>---------------------------------------------------------------------
>> >> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >>For additional commands, e-mail: user-help@struts.apache.org
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >____________________________________________________________
>> >> >6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di
>> Libero!
>> >> >Scaricalo su INTERNET GRATIS 6X http://www.libero.it
>> >> >
>> >> >
>> >> >
>> >> >---------------------------------------------------------------------
>> >> >To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >For additional commands, e-mail: user-help@struts.apache.org
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> > ____________________________________________________________
>> > 6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
>> > Scaricalo su INTERNET GRATIS 6X http://www.libero.it
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
> 
> 
> 
> ____________________________________________________________
> 6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
> Scaricalo su INTERNET GRATIS 6X http://www.libero.it
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


Mime
View raw message