Search code examples
pathelrealpath

Get real path with Expression Language


I have to get the real path of a JSP, and I have to do it with Expression Language. Then, I send the path in a TagLib.

I have found that :

<mytag:getstats rtexprvalue="${pageContext.request.contextPath}"/>

But I have a warning on rtexprvalue saying it is undefind and another in the EL : The declared exception IOException is not actually thrown by the method _elExpression15() from type __2F_PrizeWheel_2F_WebContent_2F_stats_2E_jsp.

The declaration of my TagLib in my .tld is as follow :

<tag>
    <name>getstats</name>
    <tag-class>connector.FileConnector</tag-class>
    <attribute>
        <name>name</name>
        <rtexprvalue>true</rtexprvalue>
    </attribute>
</tag>

Maybe I do it totally wrong. So if you have a better solution, I'm interested :)


Solution

    • The warning is unrelated (seems to happen randomly)
    • The "real path" is not the "context path"

    What you are looking for is ${application.realPath}