0

I have been linking my GWT app to a page written with JSP, for multifile uploading.

The gwt code to open the upload page in a new tab is:

Window.open("/secure/newuploads", "_blank", "");

This works fine in dev mode but I deployed to App Engine today and the link doesn't work: the displayed page is blank, no error code.

My JSP and JS files are located in \war. Any ideas?

Lipis
  • 21,388
  • 20
  • 94
  • 121
timmacp
  • 191
  • 1
  • 13
  • Did you try using GWT built in http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/client/ui/FileUpload.html or https://code.google.com/p/gwtupload/ – appbootup Mar 19 '13 at 03:50

3 Answers3

0

Assuming layout of war is like

-> webapps
 -> sample
  -> gwtsample
  -> jsp
  -> images
  -> css

You should use GWT.getHostPageBaseURL() to get to the root of the sample app and then move to relative jsp file. Reference image below to distinguish between module base url and hostpage url.

enter image description here

appbootup
  • 9,537
  • 3
  • 33
  • 65
  • This works in dev mode but blank still when deployed:Window.open(GWT.getHostPageBaseURL()+ "secure/newuploads", "_blank", ""); – timmacp Mar 18 '13 at 17:21
  • Can you verify if any error is shown in console? Use firebug or chrome dev tool console. – appbootup Mar 18 '13 at 17:25
  • no errors shown. Please check my summary of tests I ran today, on this page. There is a RedirectUser HttpServlet in the jsp code, its probably something to do with this, req.getRequestDispatcher("/newuploads.jsp"); I really need a gwt multifile upload project that can be used out of the box, but the 3 projects i found are problematic: 1) GWTUpload: huge, lots of missing & irrelevant libs, 2) upload4gwt: author says its incomplete (looks like its doing some something? very slowly) 3) joscarsson-gwt-gaemultiupload-example: I can't locate the uploaded blobs – timmacp Mar 19 '13 at 15:58
  • Are you sure you cannot use gwt-upload as in http://stackoverflow.com/questions/13033304/upload-multiple-files-at-once-using-gwt – appbootup Mar 19 '13 at 18:11
  • I decided not to proceed with gwt-upload sample as its too big, too many unresolved dependencies. Not worth spending more than 2 hours on such given absence of good reviews. Today I found http://www.moxiegroup.com/moxieapps/gwt-uploader/ worth a couple of hours investigation. – timmacp Mar 19 '13 at 22:20
  • Some progress with moxieapps/gwt-uploader: it calls a basic servlet ok but it doesn't use blobstore. I am trying to adapt it to use URL from BlobstoreService.createUploadUrl(URLstring). Do you know blobstore/ gwt well ? – timmacp Mar 20 '13 at 13:24
  • Sorry. Never came across multi-upload or blob-store in our app. We have example of single file upload using native gwt. – appbootup Mar 20 '13 at 13:52
  • THIS WORKS IN DEV MODE AND DEPLOYED Window.open(GWT.getHostPageBaseURL() + "newuploads.jsp", "_blank", ""); I never needed .jsp for dev mode, but need it when deployed (?). Also /secure/newuploads ?? /secure screws it up now. I have no idea what /secure is for. – timmacp Mar 20 '13 at 17:52
  • :) Well you might have to go to the dev who tried some security related trial code. – appbootup Mar 20 '13 at 17:57
0

The problem disappeared if the redirect servlet uses HttpServlet.doPost() & doGet() not service() In dev mode I was calling service() with tests if(req.getMethod()=="GET") or if(req.getMethod()=="POST")

On google's servers these don't work:

timmacp
  • 191
  • 1
  • 13
-1

You have to give the full path there. Change to:

 Window.open(GWT.getModuleBaseURL() + "secure/newuploads", "_blank", ""); 

Go through once :Getting URL's of my page ,API.

For more description about the issue you are facing refer this discussion too.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • I tried Window.open(GWT.getModuleBaseURL() + "/secure/newuploads", "_blank", ""); This gives 404 in dev mode but deployed gets the html but red 404 message : Sorry the page you were requesting is not found on the server. I guess this is jsp related. I really want to scrap this jsp but I can't find a gwt multifile upload sample that works. Surprising that App Engine development server doesn't simulate properly here. – timmacp Mar 18 '13 at 17:32
  • Your mapping to the servlet should be like appname/secure/newuploads – Suresh Atta Mar 18 '13 at 17:58
  • @timmacp Try gwtupload a third party library that makes it easier for multiple file uploads - https://code.google.com/p/gwtupload/ – appbootup Mar 19 '13 at 03:56
  • @SSR I tried GWTUpload in january, couldn't get it to compile, maybe I'll have to try again – timmacp Mar 19 '13 at 11:40
  • @Baadshah the mapping is RedirectUser com.timmacp.server.JSserver.RedirectUser RedirectUser /secure/* – timmacp Mar 19 '13 at 11:45
  • I tested basic URL vs GWT.getModuleBaseURL() vs GWT.getHostPageBaseURL() with leading / in the URL vs none, for 3 web.xml mappings: /secure/* /appname/secure/* appname/secure/* None of them work properly when deployed, and most of them screw up dev mode. The choices are 1) basic URL, is good for dev mode but page is blank when deployed 2) add GWT.getModuleBaseURL(), or GWT.getHostPageBaseURL(), gives 404 in dev mode, but a slight improvement when deployed,ie the basic html shows up but not the uploader. chrome dev tools /javascript console show no errors – timmacp Mar 19 '13 at 15:32