Image not loading in chrome but works fine in eclipse inbuilt browser












0















I am building a dynamic web application using eclipse javaEE . I am adding a background image to a jsp page by body tag attribute background().When I run this program in eclipse inbuilt browser image loads completely fine but when I run the same program on chrome , background image doesn't load.
Please help in rectifying this problem.
Thanks in advance.










share|improve this question


















  • 1





    background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

    – brk
    Jun 6 '16 at 4:48













  • no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

    – INDRESH KHANDELWAL
    Jun 6 '16 at 4:56











  • What? You're 'serving' a local static file, quite obvious that won't work..

    – Clemens Himmer
    Jun 6 '16 at 6:10
















0















I am building a dynamic web application using eclipse javaEE . I am adding a background image to a jsp page by body tag attribute background().When I run this program in eclipse inbuilt browser image loads completely fine but when I run the same program on chrome , background image doesn't load.
Please help in rectifying this problem.
Thanks in advance.










share|improve this question


















  • 1





    background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

    – brk
    Jun 6 '16 at 4:48













  • no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

    – INDRESH KHANDELWAL
    Jun 6 '16 at 4:56











  • What? You're 'serving' a local static file, quite obvious that won't work..

    – Clemens Himmer
    Jun 6 '16 at 6:10














0












0








0








I am building a dynamic web application using eclipse javaEE . I am adding a background image to a jsp page by body tag attribute background().When I run this program in eclipse inbuilt browser image loads completely fine but when I run the same program on chrome , background image doesn't load.
Please help in rectifying this problem.
Thanks in advance.










share|improve this question














I am building a dynamic web application using eclipse javaEE . I am adding a background image to a jsp page by body tag attribute background().When I run this program in eclipse inbuilt browser image loads completely fine but when I run the same program on chrome , background image doesn't load.
Please help in rectifying this problem.
Thanks in advance.







javascript java html eclipse jsp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 6 '16 at 4:47









INDRESH KHANDELWALINDRESH KHANDELWAL

848




848








  • 1





    background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

    – brk
    Jun 6 '16 at 4:48













  • no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

    – INDRESH KHANDELWAL
    Jun 6 '16 at 4:56











  • What? You're 'serving' a local static file, quite obvious that won't work..

    – Clemens Himmer
    Jun 6 '16 at 6:10














  • 1





    background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

    – brk
    Jun 6 '16 at 4:48













  • no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

    – INDRESH KHANDELWAL
    Jun 6 '16 at 4:56











  • What? You're 'serving' a local static file, quite obvious that won't work..

    – Clemens Himmer
    Jun 6 '16 at 6:10








1




1





background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

– brk
Jun 6 '16 at 4:48







background is a not a function.Instead it is a css property & to use it inline with the element you have to use the style attribute.

– brk
Jun 6 '16 at 4:48















no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

– INDRESH KHANDELWAL
Jun 6 '16 at 4:56





no,background is the attribute of body tag in html. body background="C:UsersindreshDesktopbackground.png"

– INDRESH KHANDELWAL
Jun 6 '16 at 4:56













What? You're 'serving' a local static file, quite obvious that won't work..

– Clemens Himmer
Jun 6 '16 at 6:10





What? You're 'serving' a local static file, quite obvious that won't work..

– Clemens Himmer
Jun 6 '16 at 6:10












6 Answers
6






active

oldest

votes


















0














I did face exact same issue INDRESH KHANDELWAL faced in my JAVA project.



Images weren't loading in any browser and I got this error message:




Not allowed to load local resource:




But works fine in eclipse IDE.
So I used this logic to solve this problem. Upload your image path into Database and fetch from there whenever you need the image.
Below is the code that I used for simple login page with background image,



<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>

<html>
<head>

<%
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/cart_db","root","toor");
Statement st= con.createStatement();
String sql = "select * from img_table where id = 'login_bgimg'";
ResultSet rs = st.executeQuery(sql);
String s1 = "";
if(rs.next())
{
s1=rs.getString(2); // Image URL
%>
<title> Login </title>
<link rel="stylesheet" type="text/css" href="css/Login_style.css">
</head>
<body background = "<%=s1%>" >
<div class="signin">
<form action="LoginCode.jsp" method="post">
<h2>Sign In</h2>
<input type="text" placeholder="Enter Username" name = "txtUserName">
<input type="password" placeholder="Enter Password" name = "txtPWD">
<button class = "btn">Sign In</button> <br>
<a href="#">Forget Password?</a> |
<a href="#">Create an Account</a> |
<a href="#">Back to Home</a>
</form>
</div>
<%
}
%>

</body>
</html>


Disclaimer: All, I am not an expert. I just posted what seems to be working for me. If there is a better way to handle it, please do post it here. It will be useful to me and everyone else.






share|improve this answer

































    0














    background is attribute;not a function. so remove '()' characters next to background attribute






    share|improve this answer
























    • <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

      – INDRESH KHANDELWAL
      Jun 6 '16 at 5:08











    • Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

      – Rajkumar Seenappa
      Jun 6 '16 at 5:58





















    0














    Try using in your css file



    body {
    background-image: url("<image>");

    }


    or add as inline to body tag



    style="background-image: url("image");"


    Hope this is helpful for you.






    share|improve this answer


























    • <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

      – INDRESH KHANDELWAL
      Jun 6 '16 at 5:03













    • try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

      – Naga Sai A
      Jun 6 '16 at 5:07











    • replace background attribute with the mentioned inline styling that will fix the issue for you.

      – Naga Sai A
      Jun 6 '16 at 5:08











    • Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

      – INDRESH KHANDELWAL
      Jun 6 '16 at 5:17











    • Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

      – Naga Sai A
      Jun 6 '16 at 5:19



















    0














    in HTML5 some atributes are deprecated
    you try use this in the css file
    body {
    background: url("image");



    }






    share|improve this answer































      0














      Rather then putting Absolute-Path copy past that image into WebContent and then give the path from the class path



      Now, Assume that you have your Background.png in WebContent then write CSS as below...



      body {
      background-image: url("Background.png");

      }





      share|improve this answer































        0














        The problem is probably that you're trying to server a local static file C:UsersindreshDesktopbackground.png.



        That obviously won't work, as your browser doesn't (and shouldn't) have access to your local filesystem without any prefixes, but to a specific server-hosted directory, in which all your web-hosted files should be.



        E.g. in a xampp-apache enviorment you'd have - as standard - a hosted directory like that: C:xampphtdocs. All files in this directory are reachable trough your apache web-server, as standard via localhost/....



        If you place a HTML-File and a image in this folder you may access them both relatively.



        Very basic example:



        C:xampphtdocsindex.html



        <!DOCTYPE html>
        <html>
        <head>
        <title>Your HTML..</title>
        </head>
        <body>
        <img src="image.png">
        </body>
        </html>


        C:xampphtdocsimage.png



        Any picture you'd want to serve..






        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37649704%2fimage-not-loading-in-chrome-but-works-fine-in-eclipse-inbuilt-browser%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I did face exact same issue INDRESH KHANDELWAL faced in my JAVA project.



          Images weren't loading in any browser and I got this error message:




          Not allowed to load local resource:




          But works fine in eclipse IDE.
          So I used this logic to solve this problem. Upload your image path into Database and fetch from there whenever you need the image.
          Below is the code that I used for simple login page with background image,



          <%@page import="java.sql.DriverManager"%>
          <%@page import="java.sql.Statement"%>
          <%@page import="java.sql.Connection"%>
          <%@page import="java.sql.ResultSet"%>

          <html>
          <head>

          <%
          Class.forName("com.mysql.jdbc.Driver");
          java.sql.Connection con = DriverManager.getConnection
          ("jdbc:mysql://localhost:3306/cart_db","root","toor");
          Statement st= con.createStatement();
          String sql = "select * from img_table where id = 'login_bgimg'";
          ResultSet rs = st.executeQuery(sql);
          String s1 = "";
          if(rs.next())
          {
          s1=rs.getString(2); // Image URL
          %>
          <title> Login </title>
          <link rel="stylesheet" type="text/css" href="css/Login_style.css">
          </head>
          <body background = "<%=s1%>" >
          <div class="signin">
          <form action="LoginCode.jsp" method="post">
          <h2>Sign In</h2>
          <input type="text" placeholder="Enter Username" name = "txtUserName">
          <input type="password" placeholder="Enter Password" name = "txtPWD">
          <button class = "btn">Sign In</button> <br>
          <a href="#">Forget Password?</a> |
          <a href="#">Create an Account</a> |
          <a href="#">Back to Home</a>
          </form>
          </div>
          <%
          }
          %>

          </body>
          </html>


          Disclaimer: All, I am not an expert. I just posted what seems to be working for me. If there is a better way to handle it, please do post it here. It will be useful to me and everyone else.






          share|improve this answer






























            0














            I did face exact same issue INDRESH KHANDELWAL faced in my JAVA project.



            Images weren't loading in any browser and I got this error message:




            Not allowed to load local resource:




            But works fine in eclipse IDE.
            So I used this logic to solve this problem. Upload your image path into Database and fetch from there whenever you need the image.
            Below is the code that I used for simple login page with background image,



            <%@page import="java.sql.DriverManager"%>
            <%@page import="java.sql.Statement"%>
            <%@page import="java.sql.Connection"%>
            <%@page import="java.sql.ResultSet"%>

            <html>
            <head>

            <%
            Class.forName("com.mysql.jdbc.Driver");
            java.sql.Connection con = DriverManager.getConnection
            ("jdbc:mysql://localhost:3306/cart_db","root","toor");
            Statement st= con.createStatement();
            String sql = "select * from img_table where id = 'login_bgimg'";
            ResultSet rs = st.executeQuery(sql);
            String s1 = "";
            if(rs.next())
            {
            s1=rs.getString(2); // Image URL
            %>
            <title> Login </title>
            <link rel="stylesheet" type="text/css" href="css/Login_style.css">
            </head>
            <body background = "<%=s1%>" >
            <div class="signin">
            <form action="LoginCode.jsp" method="post">
            <h2>Sign In</h2>
            <input type="text" placeholder="Enter Username" name = "txtUserName">
            <input type="password" placeholder="Enter Password" name = "txtPWD">
            <button class = "btn">Sign In</button> <br>
            <a href="#">Forget Password?</a> |
            <a href="#">Create an Account</a> |
            <a href="#">Back to Home</a>
            </form>
            </div>
            <%
            }
            %>

            </body>
            </html>


            Disclaimer: All, I am not an expert. I just posted what seems to be working for me. If there is a better way to handle it, please do post it here. It will be useful to me and everyone else.






            share|improve this answer




























              0












              0








              0







              I did face exact same issue INDRESH KHANDELWAL faced in my JAVA project.



              Images weren't loading in any browser and I got this error message:




              Not allowed to load local resource:




              But works fine in eclipse IDE.
              So I used this logic to solve this problem. Upload your image path into Database and fetch from there whenever you need the image.
              Below is the code that I used for simple login page with background image,



              <%@page import="java.sql.DriverManager"%>
              <%@page import="java.sql.Statement"%>
              <%@page import="java.sql.Connection"%>
              <%@page import="java.sql.ResultSet"%>

              <html>
              <head>

              <%
              Class.forName("com.mysql.jdbc.Driver");
              java.sql.Connection con = DriverManager.getConnection
              ("jdbc:mysql://localhost:3306/cart_db","root","toor");
              Statement st= con.createStatement();
              String sql = "select * from img_table where id = 'login_bgimg'";
              ResultSet rs = st.executeQuery(sql);
              String s1 = "";
              if(rs.next())
              {
              s1=rs.getString(2); // Image URL
              %>
              <title> Login </title>
              <link rel="stylesheet" type="text/css" href="css/Login_style.css">
              </head>
              <body background = "<%=s1%>" >
              <div class="signin">
              <form action="LoginCode.jsp" method="post">
              <h2>Sign In</h2>
              <input type="text" placeholder="Enter Username" name = "txtUserName">
              <input type="password" placeholder="Enter Password" name = "txtPWD">
              <button class = "btn">Sign In</button> <br>
              <a href="#">Forget Password?</a> |
              <a href="#">Create an Account</a> |
              <a href="#">Back to Home</a>
              </form>
              </div>
              <%
              }
              %>

              </body>
              </html>


              Disclaimer: All, I am not an expert. I just posted what seems to be working for me. If there is a better way to handle it, please do post it here. It will be useful to me and everyone else.






              share|improve this answer















              I did face exact same issue INDRESH KHANDELWAL faced in my JAVA project.



              Images weren't loading in any browser and I got this error message:




              Not allowed to load local resource:




              But works fine in eclipse IDE.
              So I used this logic to solve this problem. Upload your image path into Database and fetch from there whenever you need the image.
              Below is the code that I used for simple login page with background image,



              <%@page import="java.sql.DriverManager"%>
              <%@page import="java.sql.Statement"%>
              <%@page import="java.sql.Connection"%>
              <%@page import="java.sql.ResultSet"%>

              <html>
              <head>

              <%
              Class.forName("com.mysql.jdbc.Driver");
              java.sql.Connection con = DriverManager.getConnection
              ("jdbc:mysql://localhost:3306/cart_db","root","toor");
              Statement st= con.createStatement();
              String sql = "select * from img_table where id = 'login_bgimg'";
              ResultSet rs = st.executeQuery(sql);
              String s1 = "";
              if(rs.next())
              {
              s1=rs.getString(2); // Image URL
              %>
              <title> Login </title>
              <link rel="stylesheet" type="text/css" href="css/Login_style.css">
              </head>
              <body background = "<%=s1%>" >
              <div class="signin">
              <form action="LoginCode.jsp" method="post">
              <h2>Sign In</h2>
              <input type="text" placeholder="Enter Username" name = "txtUserName">
              <input type="password" placeholder="Enter Password" name = "txtPWD">
              <button class = "btn">Sign In</button> <br>
              <a href="#">Forget Password?</a> |
              <a href="#">Create an Account</a> |
              <a href="#">Back to Home</a>
              </form>
              </div>
              <%
              }
              %>

              </body>
              </html>


              Disclaimer: All, I am not an expert. I just posted what seems to be working for me. If there is a better way to handle it, please do post it here. It will be useful to me and everyone else.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 16 '18 at 1:42









              Rarblack

              3,00841227




              3,00841227










              answered Oct 17 '18 at 12:47









              TinuTinu

              161




              161

























                  0














                  background is attribute;not a function. so remove '()' characters next to background attribute






                  share|improve this answer
























                  • <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:08











                  • Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                    – Rajkumar Seenappa
                    Jun 6 '16 at 5:58


















                  0














                  background is attribute;not a function. so remove '()' characters next to background attribute






                  share|improve this answer
























                  • <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:08











                  • Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                    – Rajkumar Seenappa
                    Jun 6 '16 at 5:58
















                  0












                  0








                  0







                  background is attribute;not a function. so remove '()' characters next to background attribute






                  share|improve this answer













                  background is attribute;not a function. so remove '()' characters next to background attribute







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 6 '16 at 4:56









                  Rajkumar SeenappaRajkumar Seenappa

                  132112




                  132112













                  • <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:08











                  • Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                    – Rajkumar Seenappa
                    Jun 6 '16 at 5:58





















                  • <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:08











                  • Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                    – Rajkumar Seenappa
                    Jun 6 '16 at 5:58



















                  <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:08





                  <body background="C:UsersindreshDesktopbackground.png"> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is what I am doing and its working fine when I opened in it eclipse inbuilt browser but the background is not visible when I tried to access same url on chrome..

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:08













                  Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                  – Rajkumar Seenappa
                  Jun 6 '16 at 5:58







                  Image resource should be relative to the Web project rather than abstract path. For e.g. keep image in 'WebContent' path and change resource as background="background.png"

                  – Rajkumar Seenappa
                  Jun 6 '16 at 5:58













                  0














                  Try using in your css file



                  body {
                  background-image: url("<image>");

                  }


                  or add as inline to body tag



                  style="background-image: url("image");"


                  Hope this is helpful for you.






                  share|improve this answer


























                  • <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:03













                  • try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                    – Naga Sai A
                    Jun 6 '16 at 5:07











                  • replace background attribute with the mentioned inline styling that will fix the issue for you.

                    – Naga Sai A
                    Jun 6 '16 at 5:08











                  • Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:17











                  • Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                    – Naga Sai A
                    Jun 6 '16 at 5:19
















                  0














                  Try using in your css file



                  body {
                  background-image: url("<image>");

                  }


                  or add as inline to body tag



                  style="background-image: url("image");"


                  Hope this is helpful for you.






                  share|improve this answer


























                  • <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:03













                  • try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                    – Naga Sai A
                    Jun 6 '16 at 5:07











                  • replace background attribute with the mentioned inline styling that will fix the issue for you.

                    – Naga Sai A
                    Jun 6 '16 at 5:08











                  • Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:17











                  • Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                    – Naga Sai A
                    Jun 6 '16 at 5:19














                  0












                  0








                  0







                  Try using in your css file



                  body {
                  background-image: url("<image>");

                  }


                  or add as inline to body tag



                  style="background-image: url("image");"


                  Hope this is helpful for you.






                  share|improve this answer















                  Try using in your css file



                  body {
                  background-image: url("<image>");

                  }


                  or add as inline to body tag



                  style="background-image: url("image");"


                  Hope this is helpful for you.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 6 '16 at 5:27









                  Ramkee

                  5691624




                  5691624










                  answered Jun 6 '16 at 4:52









                  Naga Sai ANaga Sai A

                  6,2611927




                  6,2611927













                  • <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:03













                  • try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                    – Naga Sai A
                    Jun 6 '16 at 5:07











                  • replace background attribute with the mentioned inline styling that will fix the issue for you.

                    – Naga Sai A
                    Jun 6 '16 at 5:08











                  • Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:17











                  • Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                    – Naga Sai A
                    Jun 6 '16 at 5:19



















                  • <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:03













                  • try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                    – Naga Sai A
                    Jun 6 '16 at 5:07











                  • replace background attribute with the mentioned inline styling that will fix the issue for you.

                    – Naga Sai A
                    Jun 6 '16 at 5:08











                  • Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                    – INDRESH KHANDELWAL
                    Jun 6 '16 at 5:17











                  • Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                    – Naga Sai A
                    Jun 6 '16 at 5:19

















                  <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:03







                  <body background="C:UsersindreshDesktopbackground.png"> <div class="home"><a href="InitialPage.jsp"><img src="srcbackground.png"></img></a></div> <form> <div class="employee"> <a href="Login.jsp"><button type="button" name="employee">Employee</button></a></div> <br /> <br /><div class="admin"> <a href="Adminloginportal.jsp"><button type="button" name="admin" >Admin</button></a></div> </form> </body> </html> This is working fine in eclipse inbuilt browser but the background is not visible when I tried to access the same url on chrome...

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:03















                  try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                  – Naga Sai A
                  Jun 6 '16 at 5:07





                  try inline style as <body style=""background-image: url("C:UsersindreshDesktopbackground.png");"">.Hope this works

                  – Naga Sai A
                  Jun 6 '16 at 5:07













                  replace background attribute with the mentioned inline styling that will fix the issue for you.

                  – Naga Sai A
                  Jun 6 '16 at 5:08





                  replace background attribute with the mentioned inline styling that will fix the issue for you.

                  – Naga Sai A
                  Jun 6 '16 at 5:08













                  Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:17





                  Still its working fine on eclipse but background image doesn't load in chrome. When I googled this problem ,it has do something with context path and relative path?

                  – INDRESH KHANDELWAL
                  Jun 6 '16 at 5:17













                  Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                  – Naga Sai A
                  Jun 6 '16 at 5:19





                  Could you please rightclick on the body of the page and click inspect element and select console and check if you are seeing any error?

                  – Naga Sai A
                  Jun 6 '16 at 5:19











                  0














                  in HTML5 some atributes are deprecated
                  you try use this in the css file
                  body {
                  background: url("image");



                  }






                  share|improve this answer




























                    0














                    in HTML5 some atributes are deprecated
                    you try use this in the css file
                    body {
                    background: url("image");



                    }






                    share|improve this answer


























                      0












                      0








                      0







                      in HTML5 some atributes are deprecated
                      you try use this in the css file
                      body {
                      background: url("image");



                      }






                      share|improve this answer













                      in HTML5 some atributes are deprecated
                      you try use this in the css file
                      body {
                      background: url("image");



                      }







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jun 6 '16 at 5:56









                      Daniel Mera AlvarezDaniel Mera Alvarez

                      572




                      572























                          0














                          Rather then putting Absolute-Path copy past that image into WebContent and then give the path from the class path



                          Now, Assume that you have your Background.png in WebContent then write CSS as below...



                          body {
                          background-image: url("Background.png");

                          }





                          share|improve this answer




























                            0














                            Rather then putting Absolute-Path copy past that image into WebContent and then give the path from the class path



                            Now, Assume that you have your Background.png in WebContent then write CSS as below...



                            body {
                            background-image: url("Background.png");

                            }





                            share|improve this answer


























                              0












                              0








                              0







                              Rather then putting Absolute-Path copy past that image into WebContent and then give the path from the class path



                              Now, Assume that you have your Background.png in WebContent then write CSS as below...



                              body {
                              background-image: url("Background.png");

                              }





                              share|improve this answer













                              Rather then putting Absolute-Path copy past that image into WebContent and then give the path from the class path



                              Now, Assume that you have your Background.png in WebContent then write CSS as below...



                              body {
                              background-image: url("Background.png");

                              }






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jun 6 '16 at 6:12









                              Shalin PatelShalin Patel

                              8591915




                              8591915























                                  0














                                  The problem is probably that you're trying to server a local static file C:UsersindreshDesktopbackground.png.



                                  That obviously won't work, as your browser doesn't (and shouldn't) have access to your local filesystem without any prefixes, but to a specific server-hosted directory, in which all your web-hosted files should be.



                                  E.g. in a xampp-apache enviorment you'd have - as standard - a hosted directory like that: C:xampphtdocs. All files in this directory are reachable trough your apache web-server, as standard via localhost/....



                                  If you place a HTML-File and a image in this folder you may access them both relatively.



                                  Very basic example:



                                  C:xampphtdocsindex.html



                                  <!DOCTYPE html>
                                  <html>
                                  <head>
                                  <title>Your HTML..</title>
                                  </head>
                                  <body>
                                  <img src="image.png">
                                  </body>
                                  </html>


                                  C:xampphtdocsimage.png



                                  Any picture you'd want to serve..






                                  share|improve this answer




























                                    0














                                    The problem is probably that you're trying to server a local static file C:UsersindreshDesktopbackground.png.



                                    That obviously won't work, as your browser doesn't (and shouldn't) have access to your local filesystem without any prefixes, but to a specific server-hosted directory, in which all your web-hosted files should be.



                                    E.g. in a xampp-apache enviorment you'd have - as standard - a hosted directory like that: C:xampphtdocs. All files in this directory are reachable trough your apache web-server, as standard via localhost/....



                                    If you place a HTML-File and a image in this folder you may access them both relatively.



                                    Very basic example:



                                    C:xampphtdocsindex.html



                                    <!DOCTYPE html>
                                    <html>
                                    <head>
                                    <title>Your HTML..</title>
                                    </head>
                                    <body>
                                    <img src="image.png">
                                    </body>
                                    </html>


                                    C:xampphtdocsimage.png



                                    Any picture you'd want to serve..






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      The problem is probably that you're trying to server a local static file C:UsersindreshDesktopbackground.png.



                                      That obviously won't work, as your browser doesn't (and shouldn't) have access to your local filesystem without any prefixes, but to a specific server-hosted directory, in which all your web-hosted files should be.



                                      E.g. in a xampp-apache enviorment you'd have - as standard - a hosted directory like that: C:xampphtdocs. All files in this directory are reachable trough your apache web-server, as standard via localhost/....



                                      If you place a HTML-File and a image in this folder you may access them both relatively.



                                      Very basic example:



                                      C:xampphtdocsindex.html



                                      <!DOCTYPE html>
                                      <html>
                                      <head>
                                      <title>Your HTML..</title>
                                      </head>
                                      <body>
                                      <img src="image.png">
                                      </body>
                                      </html>


                                      C:xampphtdocsimage.png



                                      Any picture you'd want to serve..






                                      share|improve this answer













                                      The problem is probably that you're trying to server a local static file C:UsersindreshDesktopbackground.png.



                                      That obviously won't work, as your browser doesn't (and shouldn't) have access to your local filesystem without any prefixes, but to a specific server-hosted directory, in which all your web-hosted files should be.



                                      E.g. in a xampp-apache enviorment you'd have - as standard - a hosted directory like that: C:xampphtdocs. All files in this directory are reachable trough your apache web-server, as standard via localhost/....



                                      If you place a HTML-File and a image in this folder you may access them both relatively.



                                      Very basic example:



                                      C:xampphtdocsindex.html



                                      <!DOCTYPE html>
                                      <html>
                                      <head>
                                      <title>Your HTML..</title>
                                      </head>
                                      <body>
                                      <img src="image.png">
                                      </body>
                                      </html>


                                      C:xampphtdocsimage.png



                                      Any picture you'd want to serve..







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jun 6 '16 at 6:22









                                      Clemens HimmerClemens Himmer

                                      1,15111022




                                      1,15111022






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37649704%2fimage-not-loading-in-chrome-but-works-fine-in-eclipse-inbuilt-browser%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Florida Star v. B. J. F.

                                          Danny Elfman

                                          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues