This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with error page example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with error page example" Watch "Problem with error page example" New topic
Author

Problem with error page example

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

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.


Swastik
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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

Joined: Mar 15, 2009
Posts: 453

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>


SCJP 5.0 SCWCD 5.0
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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

Joined: Apr 20, 2009
Posts: 804
    
    1

Maybe it should be "jpg" instead of "jpeg" and "\" instead of "/" if you use Unix.


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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

Joined: Apr 21, 2008
Posts: 432
Hi, Veena.

What is the file extension of image, 'IMG_5636group' in 'images' folder? I guess, it is not '.jpeg'.
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
I verified it again.Extension is JPEG .
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
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

Joined: Jun 20, 2002
Posts: 442
Hello Chinmay,

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

Thanks
Veena
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I verified it again.Extension is JPEG .

With Windows Explorer, when you double click the file, do you see the image ?


[My Blog]
All roads lead to JavaRanch
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

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

Joined: Jun 20, 2002
Posts: 442
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Jun 20, 2002
Posts: 442
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

Joined: Aug 03, 2008
Posts: 9303
    
  17

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

Joined: Jun 20, 2002
Posts: 442
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

Joined: Jun 20, 2002
Posts: 442
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

Now it is able to display the image.

Great.
 
jQuery in Action, 2nd edition
 
subject: Problem with error page example