I want to display a static html page embedded into a play 2.2.1 project.
I have created a play 2.2.1 project.
I have put my whole static html files with its assets(js, css, img ect.) into the public folder of play.
I also have deleted the precreated controller and views packages.
My routing file looks the following:
GET /comingSoon.html controllers.Assets.at(path="/public", file="comingSoon.html")
However, when I go to http://localhost:9000/ I get:
I really appreciate your help!
Hm, I don't get it, actually Play told you that you didn't create any route for path / ;)
just add this route:
GET / controllers.Assets.at(path="/public", file="comingSoon.html")
Related
I'm working with something called JasperReports, and in my servlet, there's this piece of code:
JasperExportManager.exportReportToHtmlFile(jasperprintobject,"C:\\Users\\user\\Desktop\\reports\\myreport.html");
This creates an html file called myreport.html in the reports folder on my desktop, and it also creates a folder called myreport.html_files containing images that myreport.html points to, also inside the reports folder.
I would like to serve this content to the user.
Unfortunately, it seems that the exportReportToHtmlFile method won't let me put the html file inside WEB-INF.
If I could, I would just do:
request.getRequestDispatcher("/WEB-INF/myreport.html").forward(request,response);
I'm thinking about creating a jsp page that can somehow include the html file inside it and forwarding the user to the jsp page, but I'm not sure how to do this.
This is a dynamic web project in eclipse and I'm using tomcat 8.5
Does anybody have any ideas?
Thanks.
I have a spring web project which basically Test webApp and capture screenshot of pages. The path of the saved image looks something like below:
"\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
\Demo\WEB-INF\Results\Test\1118015800\error\error_ST001_1.jpg"
I am trying to display the saved image on a JSP page and so far success has been elusive. I tried different combination of relative path also I tried to give absolute path but it doesn't work. My image tag looks something like this
<img src="<c:url value="/WEB-INF/Results/Test/1118015800/error/error_ST001_1.jpg" />" />
Does anyone have any idea on displaying the image? Could it be because files are stored inside the .metadata folder of Eclipse workspace that I am not able to display any image?
This is because the WEB-INF directory is special. The web container won't serve files from that location - that behavior is defined in the Servlet Spec.
You can either create a servlet that takes requests from the client, loads images (e.g. using getResourceAsStream()) and streams them back, or move the images to a different place in your web app hierarchy.
I am a bit confused about how to deal with html and images on Google App Engine:
I am displaying a simple website on my naked domain (example.com), which is hosted on my Google App Engine directly in the war directory. This is working fine.
I have also built an API which I host on Google App Engine, and is available on example.com/api/v1/. Now, I am building a functionality in which a new user is being created and a registration confirmation mail is sent to the new user.
This email is a plain HTML page, which I load from war/WEB-INF/mail/register.html, because I do not seem to be able to get it from the war directory. In this HTML I just refer to an image with <img src="images/image.png" />, assuming GAE will search for it in /war/WEB-INF/mail/images/image.png, but this is not working. The image is never found.
I also looked at <static-files>, which needs to be placed in the app engine-web.xml, but I am a bit confused which home directory is used in this.
My question is: Can anyone explain how App Engine handles html and images in the war and WEB-INF directories?
Any help is greatly appreciated!
Note: My homepage is just working fine, so these images and css files work without any editing in the appengine-web.xml.
Note: I am using Java.
If this html is for an email, the image paths need to be the full url and not relative to the html file. For example, use:
<img src="http://example.com/images/image.png"/>
Also, images cannot be served if they are under the WEB-INF directory. Create a static directory to serve the images from.
I'm new to Spring MVC and the Spring framework in general and I'm trying to learn it.
I did a small "hello world" project using the Spring Tool Suite and encountered a strange issue. So I started a new Spring Project and chose Spring MVC Project. I created a controller and a view jsp page to display a hello page. All is working fine. There is no problem here.
Then I decided to include a picture in my jsp page. I copied a picture to the "webapp/resources" folder and put an img tag like this in my view page (whose path is "webapp/WEB-INF/views/hello.jsp"). The tag looks like this :
When I run the application and go to my view page it doesn't show the image in STS internal browser or in my regular browser. I tried to view the source of the page from my browser and the source does have the img tag but for some reason it's not shown.
I tried to put the image directly in "webapp/WEB-INF/views" along with my jsp file and changed the tag to this:
but still no success. Finally, I blamed this on my inexpirience with creating jsp's and tried to open up my regular Eclipse IDE (i.e. one different from STS) and created a Dynamic Web Project where I inserted the tag into a jsp file and copied the picture in one of the project's subfolders. I ran the project and now it works ; the picture is shown.
Why is happening this? Why it works in a regular web project and doesn't work in a Spring MVC Project? Thank you for your time and I appreciate if you help me!
I tried to put the image directly in "webapp/WEB-INF/views"
The image shouldn't be under /WEB-INF/ because this folder is not accessibile outside the app. It should be under webapp, e.g.webapp/resources/myLogo.png
and then use it like : resources/myLogo.png in the img src.
jsp files are not regular html file.
you should use <c:url /> tag to make sure your resources path are computed from the root of your project:
<img src='<c:url value="/img/mylogo.png"/>' class="logo"/>
where mylogo.png is inside WebContent/img/
I'm creating a CustomizableIntroPart for my Eclipse application. I define my pages using XHTML which works fine. But handling images is causing some trouble. I generate my content using IIntroXHTMLContentProvider, but when I generate an img-tag and set the src attribute images are not displayed. Images might be either in the executing or in some other plugins contributing to the XHTML page.
Element img = dom.createElement("img");
img.setAttribute("src", getApplicationIcon(element));
img.setAttribute("class", "appIcon");
div.appendChild(img);
I couldn't find any documentation on how to specify the source. I tried things like
plugin:my.plugin.id/icons/foo.png
Any help would be appreciated.
In the end, it's a web browser that will display your XHTML content and so it has no notion of "contributed from plugins" right?
But you are using code to process these contributions, and they're coming from either your plugin or other plugins?
If that's the case, I'd use org.osgi.framework.Bundle.getEntry(String) to get the URL to your image, and then org.eclipse.core.runtime.FileLocator.toFileURL(URL) to convert it to a file:/// URL. Then use that URL to reference your icons.
I've never used CustomizableIntroPart before, but I have successfully referred to images in different plugins using a prefix of platform:/plugin/..., like this:
platform:/plugin/my.plugin.id/icons/foo.png