0

my setup of folders in Eclipse are as below:

enter image description here

I have configured web.xml to open a welcome file as

<welcome-file>jsp/index.jsp</welcome-file>

the links, for example <img src="../images/image.jpg"/> works fine when i run like this:

enter image description here

i.e,. the individual jsp is clicked and ran on server.

But when I run the whole project on server, no links work(images, scripts, css nothing works)
enter image description here

Have tried jsp/index.jsp, ${pageContext.request.contextPath}, but cannot figure out a solution. help would be very much appreciated. :( :(

sagar
  • 79
  • 3
  • 8

1 Answers1

1

Purely because the page isn't parsed and reformatted until it's passed through the server and the jsp contents and processed.

Naturally speaking most browsers won't try and "be smart" about things and "auto look" when it "things" something "might" resemble HTML/whateverML

Once you've run the JSP through the server the serve then:

1) reads the xml and gets a bearing as to where it's "root is" i.e. / of you might be / on the hard drive whereas / for the web server could be /some/path/to/your/documents
2) reads the jsp page, parses, processes and executes whatever is in there. Usually per default TomCat (if thats what you're using) returns most output as HTML to the remote browser.

Thats why the image works... It's being seen as "part of an HTML" when it comes back from the server.

Adrian Sluyters
  • 2,186
  • 1
  • 16
  • 21