Have you tried inspecting the page source in both the cases? Do you see a difference in the image paths? Are you using relative or absolute path location for loading your images?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
If the "relative path" is relative to system and not to your web application then your assumption is right. Are these images part of your application structure, or you pulling them form different location on your system?
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
> The code does not change at all no
When I mentioned page source, I was actually talking about the generated HTML source. If you inspect the generated HTML, you should be able to find out *why* the images are not rendered based on the path used.
Anyways, AFAIK, relative paths are a problem because they depend on the current context i.e. a page served using the URL `http://localhost/app/jsp/first.jsp` would have a different context (and hence the notion of "current directory/path") from the one served using `http://localhost/app/someservlet`. To test this out, change the 'forward' to 'redirect' and the images should again show up on the page.
Almost all real world websites use "absolute" paths for providing image sources of the form <img src="${IMG_ROOT}/daiblo.jpg" /> where IMG_ROOT holds the location of the image source. It can be either located on the same server (i.e. IMG_ROOT=/images) or be a completely different site (IMG_ROOT=http://flickr.com/dean/images).
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
May be this time you can skip the servlet part and the RequestDispatcher. I don't know if it will work, but instead of submitting to the servet you can submit directly to he page you want, and put scriplets in the page.
Assuming you submit directly to a page. Then in that page you can put the java code and then display the html code
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
Ah! I found the reason for this error, atlast!
This is a snippet out of a ebook I downloaded:
Well, I did explain the same thing in my previous post:Anyways, AFAIK, relative paths are a problem because they depend on the current context i.e. a page served using the URL `http://localhost/app/jsp/first.jsp` would have a different context (and hence the notion of "current directory/path") from the one served using `http://localhost/app/someservlet`. To test this out, change the 'forward' to 'redirect' and the images should again show up on the page.what would my full server path be?
Assuming your application root is: http://localhost/ContactKeeper , the image path should be /ContactKeeper/Images otherwise if your application is the default application deployed (i.e. accessed using http://localhost ), then /Images should do the job.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Off topic, you may consider to look up some what up-to-date version of Tomcat. Version 4 was dropped long time ago. My friend "pidster" would go berserk if he seen you using it. Latest version is 7, supported version are 5 & 6, so if you not for the hotest stuff you should at least use version 6
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
The right way would be to use servlets but there is another way. Although it is not recommended by some, (I am not one of them, I usually use java in jsp pages), you can call your java methods from a jsp. If you say that the RequestDispatcher doesn't work here is another example.
Assuming that you have a page with a form and input fields and stuff. Just submit to the jsp page you want:
page1.jsp
<form action="page2.jsp">
</form>
page2.jsp:
<%
// get data from request:
String param1 = request.getParameter("param1");
...
// do some stuff
SomeClass sc = new SomeClass();
SomeObject [] obj = sc.getData(param1,....);
// display the jsp page:
%>
<body>
.....
</body>
</html>
Try to keep as little as possible the java code. Just limit your self to getting the input from request, calling methods and displaying data.
You can also get to that page by a link:
<a href="page2.jsp?param1=123123¶m2=123213">
Some Link
</a>
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448