Reputation: 357
Im just trying to pass java script variable to jsp param value dynamically below is javascript code
<script type="text/javascript">
var loginName = $.jStorage.get("loginUserName");
console.log("usrname "+loginName);
var QueryNumber="6047";
if(loginName === "admin")
{
QueryNumber="5341";
console.log("Querynumber"+QueryNumber);
$('#creater').val("desc")
$('#admin').val(QueryNumber)
}
else{
$('#admin').val(QueryNumber)
$('#creater').val(loginName);
}
$(document).ready(function () {
$('#cmschangeavailabilityLayout').layout();
});
I want to pass QueryNumber variable to below jsp param page
<div id="cmschangeavailabilityLayout" class="cmschangeavailabilityLayout" data-options="fit:true" border="false">
<input type="hidden" id="creater" name="creater"/>
<input type="hidden" id="admin" name="admin"/>
<div id="cmschangeavailabilityListView" class="cmschangeavailabilityListView" region="center" collapsible="false" border="false">
<jsp:include page="../tablefw.jsp">
<jsp:param value="${serverURL}/TableMgr" name="URL"/>
<jsp:param value="Parm1=-1&QueryNum=????&key=CMSCHANGEAVAILABILITY" name="parameters"/>
<jsp:param value="${serverURL}/addCmschangeavailability" name="addURL"/>
<jsp:param value="requestType=cmschangeavailabilityView&subRequestType=addCmschangeavailability" name="addParameters"/>
<jsp:param value="${serverURL}/editCmschangeavailability" name="editURL"/>
</jsp:include>
</div>
I want to pass java script variable QnueryNumber in this line for QueryNum like
<jsp:param value="Parm1=-1&QueryNum=QueryNumber&key=CMSCHANGEAVAILABILITY" name="parameters"/>
How can I pass it. Thanks!
Upvotes: 4
Views: 2305
Reputation: 1319
What you want to do is impossible to aquieve because JSP is rendering (executed) bu your server, it generate your html page with your javascript inside. Once it generate your html, it is then send to your browser which execute your Javascript. At this time, your JSP tags do not exist anymore they have been transformed to HTML. Even if you send your JSP has if to the browser (without rendering it), your browser won't be able to understand it.
What you should do is doing what you wanted to in JSP in Javascript. Or otherwise do everything in JSP.
What is your reason to do that (a part of your logic in JSP and in Javascript).
Upvotes: 2