It's not a secret anymore!
The moose likes Struts and the fly likes Getting the server path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting the server path" Watch "Getting the server path" New topic

Getting the server path

Steve Ashton

Joined: Sep 04, 2002
Posts: 5

I am using Struts for my application and I used to have a hyperlink in my JSP page. The link was like this <a href="<html:rewrite page="/assets/css/public.css" />">The Link</a>

However, I moved all this code into a custom taglib and when I write the code in the taglib, when it prints it out to the JSP page, it doesn't rewrite the url, it actually writes <html:rewrite page="/assets/css/public.css" /> which obviously is not what I want.

I tried a number of things such as


but this just gets the path on the C:/ drive which is not right. Can anyone let me know how I can return the server path to the right directory.

Many thanks
Steve Ashton

Joined: Sep 04, 2002
Posts: 5
I found the solution to this so I thought I would post it incase anyone ever comes across the same problem.

Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

Giving a quick glance to the api, it looks like replacing getRealPath with getResource might do the trick.

A good workman is known by his tools.
I agree. Here's the link:
subject: Getting the server path
It's not a secret anymore!