views:

348

answers:

2

Is there any way to send JSESSIONID via hidden inputs? Something like

<input type="hidden" name="JSESSIONID" value="<%= session.getId() %>"/>

I tried everything but nothing seems to be working.

It works if I directly access the other page with

www.example.com/app/q.jsp;jsessionid=CC7A1A07E117B66F4C5D8910F4F138F3

A: 

Don't put it in a hidden input, but add it as a query parameter to the "action" attribute of the form. Or, rather just use JSTL <c:url> on the action (as you should on all URLs).

Ramon
A: 

Try appending the ;jsessionid bit to the url in your form action.

An even better way is to use the JSTL <c:url> tag whenever you print a url. This will automatically ensure the jsession id is added if cookies are disabled:

<form action="<c:url value="form.jsp" />">

Phil Mander

related questions