sriram wrote:

Hi,

In my web application (using struts), I have login.jsp as welcome file.

I've defined the welcome file in web.xml as follows:

  <welcome-file-list>
    <welcome-file>/jsp/login.jsp</welcome-file>
  </welcome-file-list>

And in login.jsp, I'm using relative path to load images and style sheet.

My directory structure is as follows:

---web
     |
     |--css
     |
     |--jsp
     |
     |--images
     |
     |--WEB-INF

login.jsp is located in /web/jsp folder.

In login.jsp, I'm including style sheet as follows:
<link href="../css/style.css" rel="stylesheet" type="text/css">

"../css/style.css" --> the style sheet is located in /web/css folder.

Now, when I browse http://localhost:8080/myApp, login.jsp is displayed as welcome page, but the style sheet is not found. Same is the case with images on login.jsp. (this problem is occurring on Linux)

But when I use http://localhost:8080/myApp/jsp/login.jsp, then it is displaying everything perfectly.

And http://localhost:8080/myApp displays the login page correctly on Windows.

Any idea what could be the problem?

Sriram


The browser makes the request for the images and stylesheet relative to the path it *thinks* the login.jsp is at. In this case it sees the login.jsp page as being:


http://localhost:8080/myApp/login.jsp

so when it tries to access the stylesheet it is looking for:

http://localhost:8080/myApp/../css/style.css

which becomes:

http://localhost:8080/css/style.css

and that doesn't exist. What you can do is use some global forwards in your struts-config.xml such as
<global-forwards>
<forward name="baseStylesheet" path="/css/style.css"/>
</global-forwards>


and in your login.jsp do this:

<link rel="stylesheet" type="text/css" href="<html:rewrite forward='baseStylesheet' />" />

Then the rewrite should put in the path relative to the web application
eg it will put in the path '/myApp/css/style.css'

You can use the <html:img> tags for your images.

--
Jason Lea


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to