• 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

TOMCAT - Path to GIF files

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I guess I should have phrased my earlier question properly.
My question was which directory in TOMCAT should I put the GIF files that the Servlet uses.
My Tomcat is installed at c:\jak-tomcat
I copy the Servlet classes ( e.g. Serv01.class ) to
c:\jak-tomcat\webapps\ROOT\WEB-INF\classes
I access the Servlet using
http://localhost:8080/servlet/Serv01
My question is, in the HTML that the Servlet (Serv01) generates, if I want to include a GIF file ( pic01.gif ) as part of a IMG tag could someone please tell me how to code the path for SRC parameter ?.
Thanks
John

 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
Your post was not closed because it was not clear: it was closed because the moderator here thought that it was more appropriate in the HTML forum. Please see my answer there. Also, next time please try to double check the reason your thread was closed before reposting.
Thanks and welcome to JavaRanch!
Junilu
 
John Thomas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why should this question be posted under HTML and JavaScript forum ?. I believe my issue has more to do with TOMCAT.
Again, the gist of my question was where should I place the GIF files that the HTML generated by a Servlet needs and how should I code the path in the SRC parameter of IMG tag. So that when I access the Servlet using TOMCAT ( standalone mode ), TOMCAT is able to locate the GIFs.
I have posted the same question under TOMCAT forum, so far no one
has posted any replies.
Thanks for taking the time to answer my question.
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
Since you're a greenhorn, I suppose it would only be fair to tell you how things work around here:

  1. Moderators are all volunteers: we don't get paid and we do this because we want to. The folks who answer questions do so on their own time, too, for free. You may not get an answer as quickly as you want so please be patient. So,
  2. Don't post the same question to multiple forums. This creates more work for the moderators.
  3. It's the forum moderator's prerogative to move your post to another forum if he/she feels that it is more relevant there.

  4. As for your question, it doesn't really have a whole lot to do with TOMCAT per se. You just need to understand how your current context is affected when you're using servlets to generate responses. As such, I tend to agree that your post does not belong in the HTML forum. But then like I said above, it's the forum moderator's call.
    That said though, did you try out the suggestion I made in my reply in the HTML forum?
    Junilu
 
John Thomas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junuli,
I wasn't challenging the moderator's authority, but rather had a disagreement on classifying my post under HTML & JavaScript
I wish you concentrated more on the subject matter rather than wasting your time explaining the lack of monetary benefits.
Also, I don't think you are qualified enough to be a moderator because the very suggestions that you made for my problem is ample evidence of your lack of knowledge in the fundamentals of TOMCAT.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Normally I'd stay well away, but I'd like to point out that Junilu has amost 1000 posts to Javaranch. Even with general boo-keeping and conversation I think it reasonable to say he's helped several hundred (4-500?) people. Doesn't mean he deserves your respect or admiration, but it does indicate his skill and dedication.
Anyway, this thread is getting off topic and is in danger of getting moved to the Javaranch Forum

Also, I don't think you are qualified enough to be a moderator because the very suggestions that you made for my problem is ample evidence of your lack of knowledge in the fundamentals of TOMCAT.


Sounds like a personal comment to me, and we don't take kindly to that 'round these parts :}
Can we get some info from you on your setup, whats the name of your web-app (whats the context), how have you set up the directory structure etc. I've never run into a similar problem, but if we can compare how you have things set up to mine we should be able to find a solution.
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I re-read your question (got distracted by the arguments)
and I've had problems with the ROOT context too, the problem being it doesn't seem to like sub-directories (it thinks they refer to other contexts)
Simple solution is put the image in the ...\ROOT\ directory and refer to it as ... SRC="/pic01.gif"
I'll go see if I can find a solution to the whole "subdirectories-in-the-ROOT-context-in-Tomcat" thing.
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nup, tries the Tomcat docs, Javaranch and Google but couldn't find any solutions.
Looks like you'll have to create a "real" context and then you can safely refer to sundirectories within that context.
If you do find a solution to this I'd be interested in hearing it,
ta,
Dave.
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did misread your question when I closed it the first time. I agree that it should not have gone to the HTML forum. My mistake.

------------------
Matthew Phillips
Sun Certified Programmer for Java 2 Platform
 
John Thomas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the update David !.
- John
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your HTML, put this attribute in the body tag:
onload="alert(location.pathname)"
This will tell you exactly what your path is. It's probably:
http://localhost:8080/servlet/Serv01
like you said your URL is.
You could also try location.hostName which theoretically should give you the root of the website (probably http://localhost:8080/)
Then for the image tag href attribute, you can either give it the absolute URL, or figure out the relative URL and do it like that, which is probably:
href="../images/pic.gif"
or try
href="/images/pic.gif"
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
Expertise is not a pre-requisite for moderatorship. Willingness to help others is. It also helps if you have broad shoulders and confidence enough in your own knowledge to shrug off remarks like those you made.
True, I do not know a whole lot about Tomcat as I have been working intensively with VisualAge and WebSphere for the past nine months. However, I am quite confident that I understand the basics (and perhaps a bit more) of how web servers and servlets/JSPs work.
So, I reiterate that I do not think that your issue has anything to do with Tomcat specifically. What you need to understand is the basics of the contextPath. If you understand that, you will realize that you can put your images anywhere on the Internet as long as you know how to get to them. Then you will know what to put in the IMG SRC tag.
Good luck,
Junilu

Originally posted by John Thomas:
Junuli,
I wasn't challenging the moderator's authority, but rather had a disagreement on classifying my post under HTML & JavaScript
I wish you concentrated more on the subject matter rather than wasting your time explaining the lack of monetary benefits.
Also, I don't think you are qualified enough to be a moderator because the very suggestions that you made for my problem is ample evidence of your lack of knowledge in the fundamentals of TOMCAT.


 
John Thomas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, Expertise in TOMCAT is a MUST to be a moderator's helper.
Even the MODERATOR agrees that my issue IS related to TOMCAT
I don't understand what your freakin problem is !.

 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
I have no problem and there is really no reason for you to be hostile or rude. At any rate, I asked a colleague at work about Tomcat configuration of subdirectories and he said he did have problems getting to files in subdirectories. I suggest you try looking into one of the configuration XML files for Tomcat. You still have not posted any information about your configuration -- that would be helpful. Which version of Tomcat are you using?
Also, check out the HTML source in this link: http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/sample/web/
The IMG SRC link is exactly the way I suggested to you before.
Junilu


 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John Thomas:
Didn't anybody ever tell yout that being rude does not promote a healthy
society? To me you seem like a very angry person and you clearly have severe
attitude problems. I can't believe that you can make such a big fuss just because you were misunderstood. Why can't you jsut be nice? People will like you more.
Nice people brighton others' lives and we all learn something from them.
May I also remind you that JavaRanch is supposed to be a friendly place, not a
battlefield. You wanna have a close encounter with war, go to Afghanistan.
You don't have to reply now. Just look inside you and think, think about how you can be a better person. At least for 2002. Lastly, don't challenge authority because you can never win and know when to let it go!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, pull your head in, you two!
Don't make me turn the hose on you!
Um, I keep getting distracted, have we solved the problem or are we just arguing now? If we're still arguing I can get the thread moved to MD if you want.
Dave.
 
John Thomas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
Finally I figured out , where to place the GIFs and how to code it in SRC parameter
As I said earlier, I copy all my Servlet classes to
C:\jak-tomcat\webapps\ROOT\WEB-INF\classes

Copied my GIF file (pic01.gif) to
C:\jak-tomcat\webapps\ROOT\

In my HTML file, for the SRC I coded
SRC='/pic01.gif'
(If Windows Explorer's properties say the pic01.gif is PIC01.GIF then you need to code in upper case )
What I was missing was the slash '/' before pic01.gif
The above solution is for a TOMCAT installation out of the box, with no changes to server.xml or any new Context entries.
In case you wondered how I figured this out...
Internet Explorer , when it is unable to load a pic shows a cross ( X ) at that particular location . Right click on the cross and under properties it will tell you the actual path where it tried to load from .
In my case it was http://122.76.141.31:8080/servlet/pic01.gif , which led me to believe that TOMCAT expected pic01.gif at the root, which prompted me to put a '/' before pic01.gif
Thanks for all your help !
Junuli, you are a nice guy. I should have appreciated your well intentioned replies.
Ernest, Pope in Italy needs people like you !

 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Thomas:
Sure, Expertise in TOMCAT is a MUST to be a moderator's helper.
Even the MODERATOR agrees that my issue IS related to TOMCAT
I don't understand what your freakin problem is !.


Actually, I said no such thing. I simply said that I made a mistake by moving this to the html/javascript forum. If I thought it was a Tomcat issue, I would have moved it to the Apache/Tomcat forum.
For future reference, we do request that topics be posted in the most appropriate forum only. If you feel that you have a Tomcat issue, please post your question there instead of (or in addition to) here.
Please understand that just because a person's profile states that he/she is a bartender/sheriff does not mean they know what the problem you are having is. If you do a search on my name in servlets you will see that I have provided very little assistance in this forum. My willingness to assist javaranch and my assistance in other forums put me in the position of moderator.

Let us all remember that this is a friendly place and keep it that way. Thanks.
------------------
Matthew Phillips
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Matthew Phillips (edited December 21, 2001).]
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John,
I use Tomcat 4.0.1 under Windows 2000 server and access my servlets by http://localhost:8080/examples/servlet/ServletName where "ServletName" servlet is stored in <b>webapps/examples/web-inf/classes</b> directory. I store my images in <b> webapps/examples/images</b> directory and load them in my servlet or jsp pages thru <b>webapps/examples/images</b> directory. U may try in this way....

------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!
reply
    Bookmark Topic Watch Topic
  • New Topic