tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Champlin" <ryan.champ...@firstlogic.com>
Subject Properly setting src attribute for an img tag in a JSP
Date Tue, 28 Jun 2005 03:45:13 GMT
All,

Can someone at least let me know what the proper way to set the src attribute on an img tag
is?  I've currently used relative "../img/image.jpg" and also the following:

<img src="<%=request.getContextPath()%>/img/image.jpg"/>

When using either I'm seeing the same URL show up at the browser when getting properties on
the unfound image.  I'm able to load that image in the browser using that path only after
I've taken the file name off and see the directory listing.  Then I'm able to put the image
name back in and access the image.  This is really getting frustrating as I can't get a single
image to show up in any of my JSP's.  

I even tried creating a simple HTML page, not a JSP, with an img tag and that image can't
be found either.  Same type of case as mentioned in my previous post.  It can't load the image
from that URL.  But as soon as I hack off the file name and get the directory listing I can
then readd the file name and the file will load in the browser.  Any clue??  I'm completely
stuck on this one.

Ryan

-----Original Message-----
From: Anoop kumar V [mailto:anoopkumarv@gmail.com]
Sent: Monday, June 27, 2005 4:34 PM
To: Tomcat Users List
Subject: Re: img tag's src not working for image files in a JSP in
tomcat 5.5


Even I faced this frustrating problem recently - I couldnt really
solved it and just switched images - (I created a new image and it
somehow worked)..... I am just trying to get u a workaround (not
exactly a cause analysis of your problem) - HTH

-Anoop

On 6/27/05, Ryan Champlin <ryan.champlin@firstlogic.com> wrote:
> I've tried clearing my browser cach and tried both Firefox and IE.  Neither seem to be
able to access those images at that location.  So I don't think it's the browser necessarily.
> 
> Not using SSL and don't have any security in place for this application.
> 
> Ryan
> 
> -----Original Message-----
> From: Jason Bainbridge [mailto:jbainbridge@gmail.com]
> Sent: Monday, June 27, 2005 3:46 PM
> To: Tomcat Users List
> Subject: Re: img tag's src not working for image files in a JSP in
> tomcat 5.5
> 
> 
> Sounds like a browser caching issue or maybe some referrer checking
> getting in the way although I don't how that would be setup in Tomcat.
> 
> Are you using SSL or have any other types of constriants in place?
> 
> Regards,
> --
> Jason Bainbridge
> http://kde.org - webmaster@kde.org
> Personal Site - http://jasonbainbridge.com
> 
> On 6/27/05, Ryan Champlin <ryan.champlin@firstlogic.com> wrote:
> > All,
> >
> > I've read quite a few articles on this issue and tried all the solutions given and
none of them seem to be working.
> > I'm using Netbeans 4.1 with Tomcat 5.5.  My application is using the MVC patter
so I have a controller that is using the request dispatcher to forward a request to a JSP
page.
> >
> > Basically I have an application at the context "/Company".
> >
> > I have all my images in a folder called "img" and all my JSP's in a folder called
"jsp".
> >
> > I've tried using relative paths to the image directory and the images don't show
up in the browser however if I look at the URL it seems right.
> > I right-clicked to get properties and copied the URL:
> >
> > http://localhost:8085/Company/img/image.jpg
> >
> > If I paste that into a browser I get a 404 error from Tomcat.  However, if I take
off the image name and do:
> >
> > http://localhost:8085/Company/img
> >
> > I get a listing of the image files.  If I click on the link for the image "image.jpg"
it opens the file in the browser and I see the URL as:
> >
> > http://localhost:8085/Company/img/image.jpg
> >
> > which is exactly the same as what I had manually typed in.  Doesn't make any sense
to me as to why it works one way and not the other.  Possibly a permissions issue?
> >
> > Can anyone shed some light on why I can't get my image files to show up in my JSP
pages?
> >
> > Thanks,
> > Ryan
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


-- 
Thanks and best regards,
Anoop

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message