C:url not appending jsessionid when cookies are disabled
I tried:
<c:url value="/web/pclub/userprofile" var="test">
<c:param name="userid" value="${user.id}"/>
</c:url>
${t开发者_如何学运维est}
But when I check the page with cookies disabled then the jsessionid is not appended. Does anyone know why this happens?
The jsessionid
is only appended when the cookies are disabled and when a session has been created on the server side (and thus the server side needs to notify the client about this somehow, for which a cookie would is the default approach). If no session has been created, then there's no point of appending the jsessionid
.
Try adding the following line to top of your JSP, at least before the <c:url>
line is called. It not only prints/debugs the session ID for you, but it also implicitly creates the session if not done yet.
${pageContext.session.id}
Do this for testing purposes only. If it works, then the cause of your problem is that there was just no means of a session. Just keep it as is. There's no need to unnecessarily create the session. For the case whenever there's as session and the browser doesn't support cookies, the c:url
will work fine.
By the way, to verify if the cookies are indeed disabled, track the request headers by Firebug. If there's no Cookie
header in the request even though the server has set a Set-Cookie
header in the response, then it means that the cookies are indeed disabled in the client side.
I think BalusC is right, however to force creating a session on the server, you can add a directive page on the top of your JSP, like this:
<%@ page session="true" %>
精彩评论