Smartgwt images on tomcat - image

Using smartgwt 2.4.0 i have created a war. Running on jetty everything works fine.
But once I deploy my war on tomcat, everything works fine except for my images; like the logo.
My smartgwt is mavenized, I dont know if this causes the problem. Anyways my path to my images is: src/main/webapp/images
So bassicly in my webapp I've created a directory images. When I check my war, this directory exists, altho tomcat seems to refuse to load my images.
In my java code I set a certain image like so (again on jetty it works fine, except for tomcat):
Img logo = new Img("/images/logo.png", 1000, 100);

Use server-relative URLs to all external resources like images, stylesheets, script files, etc.
Server-relative URLs begin with the context path to the web application. If your web application is mapped to context path /mywebapp and your images are in the folder images at the root of the context path, the correct URL to logo.png would be:
/mywebapp/images/logo.png
Having said that, use Apache to serve static content, requiring Tomcat to serve only dynamic content.

Related

No images on Nuxt static site after running npm run generate

I am working on a small nuxt website for a client, i havnt been using nuxt for very long but so far what i do is add target: "static" to the config when i'm ready to build for production, then send the dist folder to backend for deployment, but now i notice that after i run npm run generate images and others assets like js files do not get added to he page.. i have tried to create a new dummy project just to test, chose static mode when setting up the project, added 1 image to the project and display it in index page using
<img src="~/path-to-file" />
the image will appear normally in dev server, will also appear if project is hosted on netlify, but will not appear in git-pages or local apache server
i am confused on why this is happening, typically adding target static fixes issues like this but not this time, please help
There are two main ways to display images through nuxt. One via the assets folder, the other via the static folder.
Any images in the /assets folder will be bundled with webpack. These images can be referenced using:
<img src="~/assets/image.png"/>
If you do not want images to be bundled by webpack, then save them in the /static folder and reference using the following format:
<img src="/image.png"/>
Currently, you are using ~/ , which is shorthand to the base directory. Once you build your site for production this will no longer work, because the structure is transformed - which is why there is a discrepancy between your environments.

Posting site to IIS - cannot find files

I have created a small site, on IIS express all is working fine. I have created on IIS new application and deployed the package to the folder. the server side is asp.net webapi. the bundle configuration is loading fine when i try to enter the home page, how ever the java script files which are referenced on the cshtml page cannot be found
<script src="~/Client/lib/require/require.js" data-main="../../Client/app/requireConfig"></script>
i am getting -
require.js
/Client/lib/require --> 404 cannot be found
and the bundle which works
viewingPanelDirective.js
/NGWeb/Client/app/appComponents/viewingPanel
how can I over come it?
I think i know what might be the cause, i had the same problem myself
in you visualstudio, the js file was running on a url like this
http://localhost:/client/lib/require/require.js
now you published it, and added it as an application to your default site, you would have given it an alias (e.g) "testsite"
meaning that in reality the file is hosted at
http://localhost/testsite/client/lib/require.js
but in reality your site is looking for it (because of the ~) at
http://localhost/client/lib etc etc
Edit in response to comment:
rather than removing the ~ (which you will need to navigate you back to the url root), i would rather just include your app name in the bundles virtual path, like this:
bundles.Add(new styleBundle("~/yourAppName/Content/css")) ....... etc
I also came across this post, I haven't tried it myself but it seems an interesting alternative to my method.
Fixing Relative CSS Paths when using .NET MVC 4 Bundling

Meteor Images, CSS, "Normal" Web Serving

I've seen this question come up a lot;
How do I put images on my Meteor website?
How do I host "standard" web content with Meteor?
I tried adding a <img src="img/myimage.png"> tag but no image shows!
How can I host some files on a Meteor site?
Put the content in a folder named "public" in your project root.
You do not need to include /public in your URLs.
Any additional folder structure within public is supported.
NodeJS routing plugins are not required, as other answers have supplied.
Place external library's javascript files in /lib. They will be automatically included.
Explanation
In Meteor, you can host "standard" web content by creating a "public" directory in the root of your project. Any images, files, or data you place in this folder will be served as normal by the NodeJS server, as if they were in the root of the server.
Example
Structure within project: /public/test/img.png
Corresponding image URL: /test/img.png
Example HTML tag: <img src="/test/img.png"/>
Create a new folder public inside the project directory. Add a new folder img (or any other name of your choice) inside the public folder. Copy all the images that you require to be added in to your HTML into this folder.
Now you can use it like - <img src="img/myimage.png">
You don't need to include /public in the in the URL.

Unable to view images in mvc3 application hosted in iis 7

I have hosted my asp .net mvc3 application in iis server 7. I had deployed my application under a virtual directory and url to my application is like www.abc.com/virtualdirname . Application works fine and Im able to navigate through pages. However , Im unable to view any images used in my application. I have stored my images in a folder public/images .
cshtml code for one of the image is as follows
img id="start" src="../../Public/images/start_button_start.png"
Im getting error message in place of images and path of image is www.abc.com/public/images instead of www.abc.com/virtualdirname/public/images .
In the app settings of my config file, I had defined virtual dir.
add key="virtualdir" value="/virtualdirname " /
Can anyone tell me why this problem happens and how can I get out of this?
Never hardcode urls in an ASP.NET MVC application. Always use url helpers:
<img src="#Url.Content("~/Public/images/start_button_start.png")" alt=""/>
Url helpers will take virtual directory into account.

Why are images not getting served on starting production server?

I have a Rails 3.1.0 application on a live server which when started in development mode serves all images and favicon.ico nicely.
But when the same app is started in production environment, the favicon image/other images in public folder are not served and their paths throws a 404 error (Interestingly, the static images of the 404 page are also not served). Any clue Rails Gods?
I am using NginX + Unicorn + Rails 3.1.0. Assets pipeline is used for everything except for 404/500 error pages and favicon.
I needed to show the files in my public folder in production mode too. I set "config.serve_static_assets" to true in "config/environments/production.rb", and it worked.
Have you tried moving all your images to app/assets/images instead? That is where the asset pipeline in Rails 3.1 serves images from. (For example, in a fresh 3.1.0 app, the rails.png file is now in app/assets/images instead of 'public/images').
FYI; if you're pulling up CSS background images, then you need to put in 'assets/imagename.jpg' instead of the old route of even just 'imagename.jpg'

Resources