• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with error page example

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying the example from HFSJ in page 468


errorPage.jsp is in webapps/ch9 folder




images folder is in ch9 folder

But when I access errorPage.jsp using url http://localhost/ch9/errorPage.jsp image doesn't get displayed.img tag has src value as src="images/IMG_5636group.jpeg".Am I giving the path in src attribute wrongly ?

Thanks
Veena
 
Swastik Dey
Rancher
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the pasted code nothing is there in img tag, and make sure you are giving the file name correct. i.e jpeg/jpg.
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is img tag part

< img src="/images/IMG_5636group.jpeg">

I am spelling file name and extension correctly.I tried putting it under different directories ,it is not working.Pleas can anyone help with this?
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veena Pointi wrote:This is img tag part

< img src="/images/IMG_5636group.jpeg">

I am spelling file name and extension correctly.I tried putting it under different directories ,it is not working.Pleas can anyone help with this?


put the image directory directly under your web-app root directory and use remove "/" in your img src="images/.... "

avi sinha>
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
img tag has src value as src="images/IMG_5636group.jpeg"


This is img tag part
< img src="/images/IMG_5636group.jpeg">

you are giving two different src attributes. Please tell us which one you are using. If you start the src with /images, then it should have the application's context path as a prefix (using ${pageContext.request.requestURI} and if you are uisng the relative path images, then the request URL must not contain any sub-directory of your app (which according to the URL http://localhost/ch9/errorPage.jsp is not so it should work...
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My image is under " webapps\ch9\images " and my jsp is under "webapps\ch9"

I tried both img src options

img src="images/IMG_5636group.jpeg"

and

img src="/images/IMG_5636group.jpeg"

It is not working for either of the option.

Thanks
Veena
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it should be "jpg" instead of "jpeg" and "\" instead of "/" if you use Unix.
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It didn't work . Sorry . No luck . I hope if some one can try this example of including img in jsp. I am using Windows XP OS
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Veena.

What is the file extension of image, 'IMG_5636group' in 'images' folder? I guess, it is not '.jpeg'.
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I verified it again.Extension is JPEG .
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Veena.

I tested in Tomcat5.5.9, Mozilla Firefox3.5, with windows OS. It is working fine. Is there any <mime-mapping> headers present in your 'web.xml' related to 'jpeg' images? Can you please post, what message you are getting while accessing the image?
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Chinmay,

Thank you for replying . The problem is it simply doesn't display the image.

Thanks
Veena
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I verified it again.Extension is JPEG .

With Windows Explorer, when you double click the file, do you see the image ?
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you access the image directly by typing a URL in the browser i.e. http://localhost/ch9/images/IMG_5636group.jpeg ??
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you access the image directly by typing a URL in the browser i.e. http://localhost/ch9/images/IMG_5636group.jpeg ??

Ankit,when I try to access using above url,it doesn't display the image.It throws 404 error saying requested resource not available.

Christopher,I am able to access the file by double clicking on the image file in explorer.

Thanks
Veena
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to see exactly how your directory structure looks like. Use the Command Prompt. Go to your webapps/ch9 directory. Type "dir" and post the result here. Then go under the "images" directory, and type "dir" again. Post the results.
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exact Directory structure


C:\apache-tomcat-5.5.27\webapps\ch9>dir
Volume in drive C has no label.
Volume Serial Number is B873-1640

Directory of C:\apache-tomcat-5.5.27\webapps\ch9

12/08/2009 02:13 PM <DIR> .
12/08/2009 02:13 PM <DIR> ..
11/27/2009 08:11 AM 96 badPage.jsp
11/29/2009 01:20 PM 373 ccatch.jsp
12/02/2009 01:28 PM 875 cforeach.jsp
11/24/2009 01:32 PM 390 cforward.jsp
12/07/2009 07:08 PM 239 cimport.jsp
12/02/2009 11:22 AM 274 cout.jsp
12/08/2009 02:14 PM 257 cparam.jsp
12/07/2009 06:36 PM 969 cset.jsp
12/07/2009 06:49 PM 417 cset1.jsp
12/01/2009 09:10 AM 307 customTagTestBean.jsp
11/21/2009 02:29 PM 101 DemoFlush.jsp
12/07/2009 02:41 PM 134 errorPage.jsp
11/21/2009 02:28 PM 10 errorProne.jsp
12/08/2009 02:14 PM 89 Header.jsp
11/27/2009 08:13 AM <DIR> images
12/08/2009 01:51 PM <DIR> WEB-INF
14 File(s) 4,531 bytes
4 Dir(s) 158,125,219,840 bytes free
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:Then go under the "images" directory, and type "dir" again. Post the results.

Veena, you didn't do this part of what Christophe wrote. Go into the images directory and then do a dir there and post the result here...
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh.I am sorry.Here is everything under images folder

C:\apache-tomcat-5.5.27\webapps\ch9\images>dir
Volume in drive C has no label.
Volume Serial Number is B873-1640

Directory of C:\apache-tomcat-5.5.27\webapps\ch9\images

11/27/2009 08:13 AM <DIR> .
11/27/2009 08:13 AM <DIR> ..
05/24/2009 09:11 PM 785,617 IMG_5636group.JPG
1 File(s) 785,617 bytes
2 Dir(s) 157,904,211,968 bytes free
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get it.Extension was JPG in dos prompt.In windows explorer it was showing JPEG .
Now it is able to display the image. Thank you all for your help .
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it is able to display the image.

Great.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic