gstackoverflow
gstackoverflow

Reputation: 36996

How to write relative url in jsp?

I have following url now:

http://localhost:8080/testApp/admin/contentModeration

by this url I show jsp page.

At this jsp page I want to render image with url:

http://localhost:8080/testApp/admin/createCompany/getSmallThumbnail/1

testApp is a shifting parameter.

<c:url value="admin/createCompany/getMediumThumbnail/"></c:url>


<c:url value="/admin/createCompany/getMediumThumbnail/"></c:url>

doesn't work

How to write c:url tag ?

Upvotes: 0

Views: 975

Answers (1)

Pshemo
Pshemo

Reputation: 124275

You can get application name testApp with this expression ${pageContext.request.contextPath} so try maybe something like

<c:url value="${pageContext.request.contextPath}/admin/createCompany/getMediumThumbnail/1"></c:url>

You can also try using relative path. So if your URL looks like

http://localhost:8080/testApp/admin/contentModeration

but you want to access

http://localhost:8080/testApp/admin/createCompany/getSmallThumbnail/1

you can use .. to describe parent context of contentModeration which will be admin and then add rest of address

<c:url value="../createCompany/getSmallThumbnail/1"></c:url>

Upvotes: 1

Related Questions