• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Images are not shown in netbeans web application on jsp page

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am using netbeans and developing web application. I want to show images on jsp pages .I don't know where the problem is do I make a mistake to put images folder whether the problem in code...?Please can you help me?
folders are as below-----

mywebapplication
|______Web pages
|______Source Packages
|______Libraries
|______Configuration files

and Web pages contains as below

Web pages
|______page1.jsp
|______index.jsp
|______page2.jsp
|______WEB-INF
|______images

and images contains as below

images
|_______logo.png
|_______sunday_logo.jgp
|_______home_img_001.png



I read topics about images in java but though I follow solutions I don't get expected output. I do the code as below


Thank you in advance
 
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your code you are using sunday_logo.jpg but in the directory structure its not present.
Can you check if the given file is present in the images folder?
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes there is file sunday_logo.jpg
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in img src, use "/" as "/images/sunday_logo.jpg"
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sumit Patil wrote:In your code you are using sunday_logo.jpg but in the directory structure its not present.
Can you check if the given file is present in the images folder?




The file is present sunday_logo.jpg

I also tried code as "../images/sunday_logo.jpg"
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still not showing image I also tried hardcoded path such as "c:/.../images/sunday_logo.jpg" but that too doesn't works...
Help me please
Thank you
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless your web app is the ROOT web app, starting the path with "/" (or "\") is incorrect. Using a local path like "C:/" also won't work.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have hard coded the location and still its not showing, it means the file name you have mentioned is not present at the given location. Check the filename, extension.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remove the "/" in front of images and try again.
Sorry i misinterpreted your directory structure.
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:Unless your web app is the ROOT web app, starting the path with "/" (or "\") is incorrect. Using a local path like "C:/" also won't work.


Sorry, But I don't understand what you exactly want to say..can you please explain it. and I am using netbeans .
Thank you
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sumit Patil wrote:Remove the "/" in front of images and try again.
Sorry i misinterpreted your directory structure.


File extension is .jpg and I also tried '/' as you suggested but when I run the file in google crome and inspect the image element and open link in new tab it indicates path as http://localhost:8080/images/sunday_logo.jpg
and show error as--

HTTP:status 404
GlassFish Server Open Source Edition 3.1.2
The requested resource () is not available
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my last post, i said to remove the "/" in present in front of images i.e

img src="images/sunday_logo.jpg"

please try this. and also close the img tag.

 
Ranch Hand
Posts: 73
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this line of code.


if it still doesn't work then use extension as .jpeg :)
even after this it doesn't work then move sunday_logo.jpg image to the images folder inside web pages and write as



 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I tried as you suggested Sir,

But Same problem is there
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish Agre wrote:try this line of code.
.............


I tried both options .I have searched on google too. from 2 days I am trying to solve this problem but where is mistake I can't find it out...!!....:(

When I inspect element and open link in new tab it shows path as....

http://localhost:8080/images/sunday_logo.jpg in browser's url

Thank you
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


http://localhost:8080/images/sunday_logo.jpg in browser's url



As you can notice, the URL formed for the jpg file is not correct. The application name is missing from it.
Can you please stop Tomcat server, delete the folders in work folder of Tomcat and try again? Also clear the history of your browser.
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Sumit Patil

Before starting netbeans I always stop tomcat. Becouse Netbeans indicates to stop server anather server is running glassfish server..

Now also it is stoped.
Thank you
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your app is deployed on Tomcat or Glassfish?
What i wanted to say was to clear the cache of the server on which your app is running. This ensures that the server is not processing the request from the cache it is maintaining.
Also it might be helpful to clear the cache of the browser as the above logic implies to browser also.
Hope this helps.
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May I send you screan-shots ?
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sumit Patil wrote:Your app is deployed on Tomcat or Glassfish?
..............
Hope this helps.



It's glassfish .........I cleared cache too...
nothing change
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My project is located at.....
C:\Users\Documents\NetBeansProjects\sunday


now folders inside sunday are
build,images,nbproject,src,web,menu,build.xml

jsp psges are inside the web folder
Thank you
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shilpa deshmukh-kadam wrote:My project is located at.....
C:\Users\Documents\NetBeansProjects\sunday


now folders inside sunday are
build,images,nbproject,src,web,menu,build.xml

jsp psges are inside the web folder
Thank you


In your first post, you mentioned the location of images folder as myapplication-->web pages-->images.
Now which is the correct path? Where is the sunday_logo.jpg is located? point the img tag to proper location of the jpg file and it will work.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a typical problem that arises when running a web app in an IDE instead of a proper servlet container. My guess would be that you would have long since solved the problem if the IDE was not part of the equation.
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sumit Patil wrote:......In your first post, you mentioned the location of images folder as myapplication-->web pages-->images.
Now which is the correct path? Where is the sunday_logo.jpg is located? point the img tag to proper location of the jpg file and it will work.




Sorry sir,
First is correct
But the path of whole folder mywebapplication is such as below

C:\Users\Documents\NetBeansProjects\mywebapplication

This one is correct path and first one is too correct becouse in first post I don't tell you where exactly mywebapplication folder is ....!!

e.g path of sunday_logo.jpg is
C:\Users\Documents\NetBeansProjects\mywebapplication\web pages\images\sunday_logo.jpg
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:This is a typical problem that arises when running a web app in an IDE instead of a proper servlet container. My guess would be that you would have long since solved the problem if the IDE was not part of the equation.


So what will be the solution when I want to use IDE...:?
Thank you
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to use the IDE? IDEs are for development, not for deployment. If the very act of using an unrealistic deployment scenario is causing problems, then the natural step would be to move towards a more realistic scenario, wouldn't you agree?
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As suggested by Tim, why don't you create a war file of your app and deploy directly to Tomcat or Glassfish? I think that will help.
And please, i am not a "Sir" you can call me Sumit :)
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both of you Tim Moores, Sumit Patil
I will try your suggestion ...

Thank You very much for giving me your valuable time....
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello once again,
I got solution for IDE .........
There is palette tab where we got image control we have to just double click on it. then browse image file with browse botton. set height and width.......then click ok
That's the solution
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>>There is palette tab where we got image control we have to just double click on it. then browse image file with browse botton. set height and width.......then click ok
That's the solution

This is funny solution.maybe you should have checked browser http code, if it says 404 , then its path problem.Again there many reasons for this path problem.Glad it got resolved.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shilpa deshmukh-kadam wrote:
There is palette tab where we got image control we have to just double click on it. then browse image file with browse botton. set height and width.......then click ok



Why don't you use your browser to see the path of the image file. This will help you learn how to add paths in a jsp/html file for later projects.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There ain't no such thing as a "netbeans web application". There are only web applications that are created/maintained by NetBeans.

If NetBeans is such a critical part of your project that you cannot conceive of how to make things work without NetBeans, you are a cripple, using NetBeans as a crutch instead of its proper use as a toolbox. NetBeans isn't going to be available on the production server. More importantly, you're outsourcing essential JEE knowledge that should be in your head, not in the IDE, and from my experience that means that you're not going to know how to use the IDE effectively, much less handle problems that arise when the IDE is not working the way you want it to.

I know it's popular for management to expect to hire unskilled, untrained monkeys that they can pay minimal wages and expect the IDE to compensate for the shortcomings of the employees, but the results of that kind of approach are abominable. If it was really possible for software to do all the work, there wouldn't be any need for the coders at all, and so far that has never been the case - or even close to it.

The best way to avoid being one of those disposable untrained (and ultimately frustrated) "monkeys" is to learn the technology without being dependent on the IDE, no matter how good that IDE might be.
 
shilpa deshmukh-kadam
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sumit Patil wrote:

Why don't you use your browser to see the path of the image file. This will help you learn how to add paths in a jsp/html file for later projects.


Definatelty ,
I will keep in mind your suggestions...I am a learner and I want to learn deeply ..


Thank you for giving me valuable suggestions ....with our above whole discussion I learn much new things about java and IDE.
In future I will need your help...Thank you
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are most welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic