Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in including jsp file dynamically  RSS feed

 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have some problem in including a jsp file dynamically.
please help me in solving it....

here is Admin.jsp >>>>>>>>>>

<%
String action=(String)request.getAttribute("action");

%>

<HTML>
<HEAD>
<TITLE> Administrator</TITLE>

</HEAD>
<body>
<table width="100%" border="5" height="100%">
<tr>
<th>User Administrator Task</th>
</tr>
<tr> <td>
<table cellpadding="0" cellspacing="0" height="100%">
<tr>
<td width="80%" align="center" bgcolor="#ffb0ff" valign="top">
<%
if(action.equals("addExe")){
%>
<jsp:include page="AddExe.jsp" flush="false"/>
<%
}else if(action.equals("delExe")){
%>
<jsp:include page="DelExe.jsp" flush="false"/>
<%
}
}
%>
</TD>
</TR>
</table>
</td></tr>
</table>
</BODY>
</HTML>

In this file when action=addExe then it is including AddExe.jsp using<jsp:include>
__________________________________

here is AddExe.jsp <<<<<<<<<<<<<<<<<<<


<%
String selectServer=(String)request.getAttribute("serverName");

%>

<html>
<head>
<title>Add New Executable</title>
</head>

<body>
<table>
<tr>
<td>
<form method="get" ACTION="AddExe.jsp" name="addExeForm" id="addExeForm">
<table>
<tr>
<td>
Select Server :
</td>
<td>
<select name="server" onChange="document.addExeForm.submit();" >
<%
if(selectServer!=null && !selectServer.equals("Select Serve")){
%>
<option><%=selectServer%></option>
<%
}else
%>
<option>Select Server</option>
<%
Databaseservers=DataBaseFactory.getInstance();
ListserverList=servers.getServers();
Iterator iter=serverList.iterator();
while(iter.hasNext()){
String serverName=((Server)iter.next()).getName();
%>
<option value="<%=serverName%>"> <%=serverName%> </option>
<%
}
%>
</select>
</td>
</tr>
</table>
</form>
</td>
</tr>

<tr>
<td>
<form method="post" action="AddExecutable" name="addform">
<table>
<tr>
<td>
Select Resource :
</td>
<td>
<select name="resource">
<option>Select Resource</option>
<%
String selectedServer=(String)request.getParameter("server");
if(selectedServer!=null && !selectedServer.equals("Select Serve")){
Databaseresources=DataBaseFactory.getInstance();
List resource=resources.getResource(selectedServer);
Iterator itr=resource.iterator();
while(itr.hasNext()){
String resourceName=(String)itr.next();
%>
<option value="<%=resourceName%>"> <%=resourceName%> </option>
<%
}
}
%>
</select>
</td>
</tr>
</table>
</form>
</td>
</tr>
</TABLE>
</body>
</html>
This is AddExe.jsp which is included in admin.jsp when user send request as action=addExe.
This jsp contain two form tag and inside this forms there is select tag,In this I am retriving value from database and put it in comboBox.
First combobox contain servername and Second ComboBox contain Resourcename.
when user select server from first comboBox then it will display all the available resource for that server.
This is working of AddExe.jsp
_________________________________

I am inclusing this jsp(Addexe.jsp)in Admin.jsp
Now the problem is that when user select server from a first comboBox then it is displaying Addexe.jsp ,but i want it to remain on the same page(Admin.jsp).I think there is some problem with first <form> in AddExe.jsp.

Please explain me what i have to do to solve this problem .
I Included Addexe.jsp in Admin.jsp and when i make a change in first comboBox then it is taking me to Addexe.jsp page but i Want it to remain on same page(Admin.jsp)

please help me in solving this problem.

thanx in Advance.
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your AddExe.jsp your form's action is "AddExe.jsp", which means that when you submi9t the form, it calls AddExe.jsp in stead of "Admin.jsp" which includes AddExe.jsp

So try setting your action in the form 1n AddExe.jsp to "Admin.jsp"

Hope it works!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!