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?
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.
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:
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.
Related
Hi guys I'm new to play framework,
Qun 1:
what I wanted in my server is Users can upload images, and see uploaded images in web page,
when I run the server in Dev mode everything is works fine (I can upload and see the images in web page),
but I try do this same thing in production mode, uploading works fine(images saved in public directory) but images are not visible in web page...!
my twirl html template:
<img src="#routes.Assets.versioned(public/file1.png)" width=25% height=auto alt="file1.png">
routes:
GET /versionedAssets/*file controllers.Assets.versioned(path="/public", file: Asset)
browser's Elements page (F12):
<img src="/versionedAssets/file1.png" width="25%" height="auto" alt="file1.png">
I can even show the image using NGINX (passing image location as an url) successfully,
but why i can't see the image in play's production mode?,
I don't even have clue about what part I did wrong.!
please help me if you know anything about it.!
Qun 2:
Is that possible to serve our app without frontend server like NGINX, etc.
because play already running in AkkaHttpServer.
After reading docs
I've found Ok.SendFile() method used to serving files, then I've created a method in controller
def getImageFromPath()= Action{ implicit request: Request[AnyContent] =>
Ok.sendFile(new java.io.File("/path/to/file")) }
then added route in routes file
GET /getimage controllers.ImageController.getImageFromPath()
reverse routing in Twirl template
<img src="#routes.ImageController.getImageFromPath()" width=25% height=auto alt="file1.png">
helped me to solve this issue..!
I am using the blueimp jQuery-File-Upload on SpringSource Tool Suite 2.9.1.
I am trying to redirect from my UploadServlet , but because the option redirect is already
defined (on main.js) it create an error.
how can I redirect from my UploadServlet.java , after the files are uploaded .
In the example code they redirect to results.html , When I try this it upload the files but
after doPost function finish (in my UploadServlet.java) nothing happens & It doesn't
redirect .
please help me and give me an example how to do those thing .
Thanks
Tami
I've been through a similar issue when using the plugin on Google App Engine. Here is the complete working code. May be you'll have slight differences, but I guess you'll find how a Java server have to be done for this plugin to work.
I have a servlet which returns as response an html page that also includes pictures. I have those pictures stored on the file system in the Pictures folder (path: /home/andrei/Pictures).
I currently have there just one photo(name: eu.jpg ) but i will add more.
So the point is that in the html code i somewhere have this: <img src="/home/andrei/Pictures/eu.jpg" alt="pic" > . But when i get the html page it doesnt display neither the photo nor the "pic" text from alt(not sure if this is normal...). I read that it may be due to the path i gave in src but i dont know exactly what to give.
So what path should i give to the src?
And is it normal not displaying the alt text because i knew that when it cannot load the pic it shows that text.
Additional information:
IDE : Eclipse Juno
SO : Linux
Server: Tomcat 7.0
Any image you intend to display in a browser connecting a web container (Tomcat in your case) must be visible in the container. To do it, place the images in the webapp/ folder and link them properly from the servlet generating the correct tag where path is the correct http link to your file.
When you send back the HTML response, the client's browser will render the document and then, send requests for additional resources in order to show the HTML document fully. That includes the images, so Tomcat must be able to serve them. If you can't put them in a folder inside WebContent from the beginning, the servlet must do the move and create the document specifying the "public route".
The images should be part of the webapp. Absolute FS path will not work. <img> will take relative path, or absolute path wrt the website.
I'm just doing a java tomcat project, that does some query in a database then return the file path of some web pages.
Now I have mapped my only class in web.xml and the webapp does return a list of urls which correspond to some html pages in my local disk. I set up a side frame in the webapp, my idea is that I output the results in the output page like "file:///file_path_of_html_page" and when this link is clicked, the side frame will show the html page.
But actually I got the right links but when I click on them, nothing happens, chrome tells me "Not allowed to load local resource". Even I set the target="_blank", the link doesn't work. But the "file:///filepath" are all ok when I type them in the address bar. I've moved all the html pages in the eclipse project folder but that didn't help.
Any suggestions to do this simple task?
The average browser disallows due to security reasons opening file:// resources when the parent resource is by itself served over http://. If you make them fullworthy http:// links, then it will work properly.
Even if the browser allowed it, this approach would not going to work when you publish the webapp on a different server. A file:// resource refers to the local disk file system, which is the one the client (the user with the webbrowser) is using. This is normally in a physically different machine. The client should have a copy of exactly those resources on its own local disk file system beforehand in order to get the file:// links to work.
Just put the HTML pages in public web root of your web project (there where you normally put your JSP files and so on) and use (relative) http:// links to refer the HTML pages. For example, the following link in a http://localhost:8080/contextname/some.jsp
link to some html file
would open the http://localhost:8080/contextname/some.html file.
I have written a RIA using flex for the front-end and Java servlet for the back end which actually makes calls to a web-service to do some processing.
The welcome page is a html page which is served from the web-logic 8.1 server that the app is hosted on. The welcome page loads and the flash content loads. Even a 'xml' file containing some configuration properties gets loaded from the server (through URL Request).
Now when I click a button on the page, it would authenticate the user, by sending the data to the servlet.
Here's the problem... The servlet doesn't get invoked and the URL Request (for the servlet with appropriate parameters) returns a 500: Internal Server Error page.
The same code is working perfectly when I deploy it on my local machine using tomcat as a server. And I have also checked umpteen times if the host URL is correct when being deployed on the web-logic server. Even checked the URL when the request is being made, in firefox, using firebug, and all seems to be fine, except that the response is '500: Internal Server Error'.
Please help. Thanks in Advance.
OK, the welcome page loads, and an XML file loads from the webserver, but the servlet can't be invoked.
Is the servlet initialising correctly, and waiting to be called?
Does anything need to be changed in the web.xml file that hasn't been?
Without any more information, it sounds like a misconfigured servlet and/or app server. Check your logs to see if there's any more information there.