please stop spamming...
thx
btw,
old action-clzz of mine, i guess it works still
package net.wessendorf.web.struts.actions;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.activation.FileDataSource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.wessendorf.web.struts.files.FileDownload;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* @author Matthias We�endorf
*
*/
public class FileReaderAction extends Action {
/* (non-Javadoc)
* @see
org.apache.struts.action.Action#execute(org.apache.struts.action.ActionM
apping, org.apache.struts.action.ActionForm,
javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
ActionForward actionForward = null;
//FileDownload down = null;
try {
//response.setContentType("application-x/pdf");
//String pdfFile = (String)
request.getAttribute("pdfFile");
//if no parameter is...
C:\foo\silly.pdf instead of "pdfFile" ...
String pdfFile =
request.getParameter("pdfFile");
java.io.File file = new
java.io.File(pdfFile);
ServletOutputStream out =
response.getOutputStream();
response.setContentType("application/pdf");
// MIME type for pdf doc
System.out.println("URL: " +
file.toURL ().toString ());
String fileURL = file.toURL
().toString ();
response.setHeader("Content-Disposition", "attachment;
filename=\"Example.pdf\"");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
response.reset();
try
{
URL url = new
URL(fileURL);
URLConnection urlConn =
url.openConnection ();
response.setContentLength (urlConn.getContentLength ());
System.out.println("Content-Length: " + urlConn.getContentLength ());
bis = new
BufferedInputStream(url.openStream());
bos = new
BufferedOutputStream(out);
byte[] buff = new
byte[2048];
int bytesRead;
while (-1 != (bytesRead
= bis.read(buff, 0, buff.length)))
{
bos.write(buff,
0, bytesRead);
}
System.out.println("Flush Buffer.");
bos.flush ();
fileURL = "datei.pdf";
response.flushBuffer ();
} catch (final
MalformedURLException e)
{
System.out.println("MalformedURLException.");
throw e;
} catch (final IOException e)
{
System.out.println("IOException.");
throw e;
} finally
{
if (bis != null)
{
System.out.println("Close BufferedInputStream.");
bis.close();
}
if (bos != null)
{
System.out.println("Close BufferedOutputStream.");
bos.close();
}
}
}
catch (Exception e) {
e.printStackTrace();
actionForward =
mapping.findForward("error");
}
return actionForward;
}
}
> -----Original Message-----
> From: ganesh g [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 12, 2004 2:38 PM
> To: Struts Users Mailing List
> Subject: convert locamachine serverpath to universal
> clientpath he can download it and play very very urgent please
>
>
> Hi friends,
> You are right But i'm placing in another drive
>
> c:\clientsData\client1\client1 huge PersanalData..
>
> c:\clientsData\client2\.client2 huge PersanalData..
>
> c:\clientsData\client3\.client3 huge PersanalData..
> It's a large data.So i'm not allowed to place them in webapps
> directory.
> From there itself i've give data to clients.So i want another
> solution in detail please.
>
> Please help me Urgent
> Ganesh
>
>
>
>
> "Rosenberg, Leon" <[EMAIL PROTECTED]>
> wrote:This is not a
> struts question, but, put your file in the context of your web-app ->
> .../webserver/webapps/your-web/audioFiles/sample.wav and
> reference it in
> the jsp as /audioFiles/sample.wav
>
>
>
> > -----Urspr�ngliche Nachricht-----
> > Von: ganesh g [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 12. Mai 2004 14:16
> > An: user
> > Cc: user
> > Betreff: convert locamachine serverpath to universal clientpath he
> can
> > download it and play very very urgent please
> >
> > Hi List,
> >
> > i need ur help very urgent.
> >
> > 1)
> > My audio file path in my server is as follows:
> >
> > "c:\audioFiles\sample.wav"
> > 2)
> > i wrote javascript code snippet in a jsp file to play that
> audio file
> > where i'm sending my server
> path("c:\audioFiles\sample.wav") to play
> > audio.But client is not able to play the audio file.Here when a
> client
> > clicks on 'Play' button, audio should play.i.e.,'download' sould
> > automatically happen internally without displaying the download
> dialogue
> > box.
> >
> > What my serious problem is how to send my server path to all clients
> so
> > that they can play it.How to convert this path into
> Universal path or
> Url
> > path.
> >
> > Are there any methods or tricks??
> > i'm using struts ...
> > Pls help me. Urgent..
> >
> > Advance thanks
> > Ganesh
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Movies - Buy advance tickets for 'Shrek 2'
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]