I have a JSP page which loads another jsp page's content which is working perfectly fine. The problem is I want to pass request.getParameter("cfgname")
to this content page, so that when it is loaded into the main JSP the content is complete. (Current code shows me null
in place of request.getParameter
Here is my main JSP page which gets cfgid=41&cfgname=Abhishek&cfgdesc=test1&cfgtype=Development&filepath=files%2Fcsmclientbuckeye.xml
<title>Testing</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.get("content.jsp", addContent);
function addContent(data)
{
$("#content").html(data);
}
});
</script>
</head>
<body>
<div id="content"></div>
</body>
Content.jsp page
<table class="csm-table" width="100%" cellspacing="0" cellpadding="4" border="0">
<tbody>
<tr>
<th width="25%">Configuration Name</th>
<td width="25%"><span id="cname"><%= request.getParameter("cfgname") %></span></td>
<th width="25%">Host Name</th>
<td width="25%"><span id="chostname">{hostname}</span></td>
</tr>
<tr> </tr>
<tr>
<th>Configuration Description</th>
<td><span id="cdesc"><%= request.getParameter("cfgdesc") %></span></td>
<th width="25%">Os Name</th>
<td width="25%"><span id="cosname">{osname}</span></td>
</tr>
<tr>
<th>Configuration Type</th>
<td><span id="ctype"><%= request.getParameter("cfgtype") %></span></td>
<th>Product Name</th>
<td><span id="cproductname"></span></td>
</tr>
<tr>
<th>Last Updated Time</th>
<td><span id="clastupdatetime"></span></td>
<th>Configuration File Name</th>
<td><span id="cfilename"><%= request.getParameter("filepath") %></span></td>
</tr>
</tbody>
</table>
Both of your (Kees and Mick)'s answer helped me
I did $.get("content.jsp?cfgname=<%= request.getParameter("cfgname") %>", addContent);
which solved my problem. Thanks guys