Re: Download file from server to client - w Servlet etc PLEASE?

2012-07-09 Thread MIKE
Hi,
>
>
I got the following error. Any help please ? 

HTTP ERROR: 405

HTTP method GET is not supported by this URL

RequestURI=/name/Download

*Powered by Jetty:// *

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/w0EG54RwWQ0J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Download file from server to client - w Servlet etc PLEASE?

2012-06-29 Thread Craig Mitchell
A word of warning with downloading using Window.open, it won't work for IE8 
if your site is running over SSL.   works fine.

On Saturday, 13 September 2008 08:48:18 UTC+10, Joe Cole wrote:
>
> Make sure you use the gwt jsni equivalent to; 
>
> var win = Window.open(url, name, options); 
> if ( win ) return true; 
> return false; 
>
> Otherwise you can't detect when popups are blocked. It will save you 
> tons of time in user support if you tell them to enable popups if the 
> window wasn't opened. It amazed me how many users didn't know how to 
> enable this. 
>
> Joe 
>
> On Sep 12, 8:33 pm, Jason Morris  wrote: 
> > I assume what you want is for the client to have a new file on their 
> hard-drive. 
> > First you'll need a servlet that produces the data. I'm not sure what 
> > data-format you want to work with, so I'm gonna assume a plain text file 
> here 
> > (note, this is all typed directly into my mail client, sorry for any 
> mistakes). 
> > 
> > public class MyFileServlet extends HttpServlet { 
> > protected void doGet(HttpServletRequest req, HttpServletResponse 
> resp) throws 
> > ServletException, IOException { 
> > 
> > resp.setContentType("text/plain"); 
> > resp.setHeader("Content-Disposition", "attachment; 
> filename=output.txt"); 
> > 
> > PrintWriter out = resp.getWriter(); 
> > out.println("This is the output content"); 
> > out.println("Probably something dynamic should go in 
> here"); 
> > } 
> > 
> > } 
> > 
> > Then you'll want to write the client side to fetch the file. 
> > 
> > public class MyEntryPoint implements EntryPoint { 
> > public void onModuleLoad() { 
> > String link = GWT.getModuleBaseURL() + 
> "servlet/myfiledownload"; 
> > RootPanel.get().add(new HTML(" "\">Download File")); 
> > } 
> > 
> > } 
> > 
> > You can also use Window.open(link, "downloadWindow", ""); 
> > to download the file from an EventListener. 
> > 
> > Finally you'll need to configure the servlet in either your 
> Module.gwt.xml file 
> > (for hosted mode), or in your web.xml file for web mode. 
> > 
> > Module.gwt.xml example, add: 
> > 
> >  > class="your.package.name.here.MyFileServlet" /> 
> > 
> > web.xml add: 
> > 
> >  
> > MyFileServlet 
> > 
> your.package.name.here.MyFileServlet 
> >  
> > 
> >  
> > MyFileServlet 
> > 
> /your.package.name.here/servlet/myfiledownload 
> >  
> > 
> > Like I show in the web.xml example, you'll need to make sure that the 
> servlet is 
> > bound to the module base directory (where the nocache.html files all 
> live), and 
> > not next to the host HTML page. Another important factor is: the Servlet 
> must 
> > not be in your "client" package, since the GWT compiler shouldn't get 
> hold of it. 
> > 
> > Hope this helps. 
> > Jason. 
> > 
> > JohnnyGWT wrote: 
> > > I've seen several discussions on how to download a file to the client. 
> > > All contain bits of code but no complete examples. 
> > 
> > > FileUpload is fine & easy using Apache commons stuff. 
> > 
> > > Can someone PLEASE provide some examples etc for downloading a file to 
> > > the client? 
> > > In my scenario I have to send a newly created file to the client. 
> > > Either this is by a download servlet 'get' method or a URL. 
> > 
> > > Any full examples would be greatly appreciated. 
> > 
> > > Thanx in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/qXl7QTOMA7cJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Download file from server to client - w Servlet etc PLEASE?

2008-09-12 Thread Joe Cole

Make sure you use the gwt jsni equivalent to;

var win = Window.open(url, name, options);
if ( win ) return true;
return false;

Otherwise you can't detect when popups are blocked. It will save you
tons of time in user support if you tell them to enable popups if the
window wasn't opened. It amazed me how many users didn't know how to
enable this.

Joe

On Sep 12, 8:33 pm, Jason Morris <[EMAIL PROTECTED]> wrote:
> I assume what you want is for the client to have a new file on their 
> hard-drive.
> First you'll need a servlet that produces the data. I'm not sure what
> data-format you want to work with, so I'm gonna assume a plain text file here
> (note, this is all typed directly into my mail client, sorry for any 
> mistakes).
>
> public class MyFileServlet extends HttpServlet {
>         protected void doGet(HttpServletRequest req, HttpServletResponse 
> resp) throws
> ServletException, IOException {
>
>                 resp.setContentType("text/plain");
>                 resp.setHeader("Content-Disposition", "attachment; 
> filename=output.txt");
>
>                 PrintWriter out = resp.getWriter();
>                 out.println("This is the output content");
>                 out.println("Probably something dynamic should go in here");
>         }
>
> }
>
> Then you'll want to write the client side to fetch the file.
>
> public class MyEntryPoint implements EntryPoint {
>         public void onModuleLoad() {
>                 String link = GWT.getModuleBaseURL() + 
> "servlet/myfiledownload";
>                 RootPanel.get().add(new HTML(" "\">Download File"));
>         }
>
> }
>
> You can also use Window.open(link, "downloadWindow", "");
> to download the file from an EventListener.
>
> Finally you'll need to configure the servlet in either your Module.gwt.xml 
> file
> (for hosted mode), or in your web.xml file for web mode.
>
> Module.gwt.xml example, add:
>
>  class="your.package.name.here.MyFileServlet" />
>
> web.xml add:
>
> 
>         MyFileServlet
>         your.package.name.here.MyFileServlet
> 
>
> 
>         MyFileServlet
>         
> /your.package.name.here/servlet/myfiledownload
> 
>
> Like I show in the web.xml example, you'll need to make sure that the servlet 
> is
> bound to the module base directory (where the nocache.html files all live), 
> and
> not next to the host HTML page. Another important factor is: the Servlet must
> not be in your "client" package, since the GWT compiler shouldn't get hold of 
> it.
>
> Hope this helps.
> Jason.
>
> JohnnyGWT wrote:
> > I've seen several discussions on how to download a file to the client.
> > All contain bits of code but no complete examples.
>
> > FileUpload is fine & easy using Apache commons stuff.
>
> > Can someone PLEASE provide some examples etc for downloading a file to
> > the client?
> > In my scenario I have to send a newly created file to the client.
> > Either this is by a download servlet 'get' method or a URL.
>
> > Any full examples would be greatly appreciated.
>
> > Thanx in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Download file from server to client - w Servlet etc PLEASE?

2008-09-12 Thread Cerberus

Hi,

On 12 Sep., 09:33, Jason Morris <[EMAIL PROTECTED]> wrote:
> public class MyEntryPoint implements EntryPoint {
>         public void onModuleLoad() {
>                 String link = GWT.getModuleBaseURL() + 
> "servlet/myfiledownload";
>                 RootPanel.get().add(new HTML(" "\">Download File"));
>         }
>
> }
>
> You can also use Window.open(link, "downloadWindow", "");
> to download the file from an EventListener.

If you just want to let the browser pop up a save-as-window, you can
also do the following:

In the HTML where the GWT-application resides put in the following:



(or any other name for the id you want)

and start the download with the following code:

DOM.setElementAttribute(RootPanel.get("__download").getElement(),
"src", link);

Personally I prefer this kind of way because it behaves more like
you're
used to when working with a local application instead of being forced
to
click a link or open a popup containing nothing.


Best regards, Lothar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Download file from server to client - w Servlet etc PLEASE?

2008-09-12 Thread Jason Morris

I assume what you want is for the client to have a new file on their 
hard-drive. 
First you'll need a servlet that produces the data. I'm not sure what 
data-format you want to work with, so I'm gonna assume a plain text file here 
(note, this is all typed directly into my mail client, sorry for any mistakes).

public class MyFileServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
throws 
ServletException, IOException {

resp.setContentType("text/plain");
resp.setHeader("Content-Disposition", "attachment; 
filename=output.txt");

PrintWriter out = resp.getWriter();
out.println("This is the output content");
out.println("Probably something dynamic should go in here");
}
}


Then you'll want to write the client side to fetch the file.


public class MyEntryPoint implements EntryPoint {
public void onModuleLoad() {
String link = GWT.getModuleBaseURL() + "servlet/myfiledownload";
RootPanel.get().add(new HTML("Download 
File"));
}
}


You can also use Window.open(link, "downloadWindow", "");
to download the file from an EventListener.

Finally you'll need to configure the servlet in either your Module.gwt.xml file 
(for hosted mode), or in your web.xml file for web mode.

Module.gwt.xml example, add:




web.xml add:


MyFileServlet
your.package.name.here.MyFileServlet



MyFileServlet

/your.package.name.here/servlet/myfiledownload



Like I show in the web.xml example, you'll need to make sure that the servlet 
is 
bound to the module base directory (where the nocache.html files all live), and 
not next to the host HTML page. Another important factor is: the Servlet must 
not be in your "client" package, since the GWT compiler shouldn't get hold of 
it.

Hope this helps.
Jason.

JohnnyGWT wrote:
> I've seen several discussions on how to download a file to the client.
> All contain bits of code but no complete examples.
> 
> FileUpload is fine & easy using Apache commons stuff.
> 
> Can someone PLEASE provide some examples etc for downloading a file to
> the client?
> In my scenario I have to send a newly created file to the client.
> Either this is by a download servlet 'get' method or a URL.
> 
> Any full examples would be greatly appreciated.
> 
> Thanx in advance
> > 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Download file from server to client - w Servlet etc PLEASE?

2008-09-11 Thread JohnnyGWT

I've seen several discussions on how to download a file to the client.
All contain bits of code but no complete examples.

FileUpload is fine & easy using Apache commons stuff.

Can someone PLEASE provide some examples etc for downloading a file to
the client?
In my scenario I have to send a newly created file to the client.
Either this is by a download servlet 'get' method or a URL.

Any full examples would be greatly appreciated.

Thanx in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---