File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Passing more than one object between jsp and servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing more than one object between jsp and servlet" Watch "Passing more than one object between jsp and servlet" New topic
Author

Passing more than one object between jsp and servlet

Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
Hi
I am trying to pass two linked List objects from a Servlet to a JSP page through setAttributes method.
However I am having difficulty doing this. It looks like JSP and Servlet do not like passing two same type of objects through a session.
Once I removed one of the objects it started working. The problem does not seem to be in the servlet side it is on the JSP side, where it returns a classcast exception when I try to read the second linkedList object passed in.
Any help or pointers would be very helpful.
Regards
Gajan
Thanks
David
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

When you setAttribute, are you setting them with 2 different and distinct names?
setAttribute("List1", list1);
setAttribute("List2", list2);
could you maybe provide us with some of the JSP code you are using to do this?


GenRocket - Experts at Building Test Data
Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
The code I am using is this:
In Servlet:
public class GetPropertyDetailsServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{

...

List rents = new LinkedList();
List properties = new LinkedList();

...

String destination = "/MaintainProperty.jsp";
request.setAttribute("rents", rents);
request.setAttribute("properties", properties);

RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(destination);
dispatcher.forward(request, response);
}
}

In JSP (MaintainProperty):

...
<jsp:useBean id="rents" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="properties" class="java.util.LinkedList" scope="request"/>
...
List propertiesList = new LinkedList();
List rentsList = new LinkedList();
rentsList = (List)request.getAttribute("rents");
propertiesList = (List)request.getAttribute("properties");
...
I am able pass different objects in the above way. I am also able to pass multiple String values but when I try to pass Lists I am getting the following error:

java.lang.ClassCastException
at org.apache.jsp.MaintainProperty_jsp._jspService(MaintainProperty_jsp.java:459)
Any help would be very much appreciated.
Thnx
Gajan
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

<jsp:useBean id="rents" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="properties" class="java.util.LinkedList" scope="request"/>
...
List propertiesList = new LinkedList();
List rentsList = new LinkedList();
rentsList = (List)request.getAttribute("rents");
propertiesList = (List)request.getAttribute("properties");

I am not 100% sure about this, but what if you casted to a LinkedList instead of List so change to....
rentsList = (LinkedList)request.getAttribute("rents");
propertiesList = (LinkedList)request.getAttribute("properties");
I think the problem might be the fact that you are casting a LinkedList to a List and it probably doesn't like that. Let me know...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67


<jsp:useBean id="rents" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="properties" class="java.util.LinkedList" scope="request"/>
...
List propertiesList = new LinkedList();
List rentsList = new LinkedList();
rentsList = (List)request.getAttribute("rents");
propertiesList = (List)request.getAttribute("properties");

I'm not sure why you are getting the CCE, but the above code makes no sense.
The useBean tags make the attributes available to the page as rents and properties respectively.
Then you go an create new instances of linked lists needlessly, and then you replace them with scripting variables created from the beans.
After the useBean tags, you shouldn't have to do any of that other stuff. You can just reference the beans as rents and properties.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

He is probably using scriptlets so more than likely his code looks more like...
<jsp:useBean id="rents" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="properties" class="java.util.LinkedList" scope="request"/>
<%
List propertiesList = new LinkedList();
List rentsList = new LinkedList();
rentsList = (List)request.getAttribute("rents");
propertiesList = (List)request.getAttribute("properties");
%>
But it still makes no sense like you said, because if he is using scriptlets like that, he should be doing a @page import instead of useBean.
I guess we can keep on guessing until he responds.
BTW - I don't think it would hurt to see the entire JSP page instead of putting ... where you felt like not providing the code. It makes it hard for us to guess at what you are really trying to do.
Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
Sorry for the delay guys. I am new to JSP so didn't know if i declare usebeans i can use them staright away.
Anyway I am still having the same problem... here is the full code for the servlet - and JSP page....
Please help me.
SERVLET
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package HousingManager;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.lang.*;

public class GetPropertyServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
String varPropertyId = request.getParameter("PropertyId");
String destination;
String SQLStatement;
String secondSQLStatement;
String thirdSQLStatement;
SQLStatement = "SELECT PropertyId, PropertyAddress, PropertyArea, PropertyArea2, PropertyTown, PropertyCounty, PropertyPostCode, PropertyCountry, LeaseStart, LeaseEnd, BreakClause, PropertyTelephoneNo, PropertyFaxNo, LeaseRenewal, DepositRequired, DepositHeldBy, DepositReturned, Bedroom, Bathroom, Lavatory, Kitchen, Lounge, DiningRoom, Reception, Conservatory, Shed, Garage, AccommodationType, FrontGarden, FrontGardenSize, RearGarden, RearGardenSize, OtherPropertyInfo, GeneralPropertyComments, AgentId, NoticeDays, LetterOfGuarantee, RentPaidTo FROM Property WHERE PropertyId="
+ "'" +varPropertyId+"'";
System.out.println(SQLStatement);
secondSQLStatement = "SELECT PropertyRentId, PropertyId, StartDate, Amount, EndDate FROM PropertyRent WHERE propertyId ='"+varPropertyId+"'";
thirdSQLStatement = "SELECT PropertyFeaturesId, PropertyId, Name FROM PropertyFeatures WHERE PropertyId='"+varPropertyId+"'";
DBConnection dbCon = new DBConnection();
List list = new LinkedList();
List rents = new LinkedList();
List propertyFeatures = new LinkedList();
list = dbCon.getDBResultSet(SQLStatement, "Property");
ListIterator iterator = list.listIterator();
HousingManager.Property property =new HousingManager.Property();
while(iterator.hasNext())
{
property = (HousingManager.Property)iterator.next();
}
System.out.println(secondSQLStatement);
rents = dbCon.getDBResultSet(secondSQLStatement, "PropertyRent");
int j = rents.size();
System.out.println("rents="+j);
propertyFeatures = dbCon.getDBResultSet(thirdSQLStatement, "PropertyFeatures");

if (list == null)
{
destination = "/NoProperties.jsp";
}
else
{
destination = "/MaintainProperty.jsp";
request.setAttribute("property", property);
request.setAttribute("rents", rents);
request.setAttribute("propertyFeatures", propertyFeatures);
request.setAttribute("submitType", "SaveChanges");
}
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(destination);
dispatcher.forward(request, response);
}
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This is JSP Page
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%@ include file="topandleftbar.htm" %>
<%@ include file="DateValidationScript" %>

<script>
function ProcessForm()
{
if(document.frmProperty.ChkBoxFrontGarden.checked)
{
document.frmProperty.FrontGarden.value = 1
}
else
{
document.frmProperty.FrontGarden.value = 0
}

if(document.frmProperty.ChkBoxRearGarden.checked)
{
document.frmProperty.RearGarden.value = 1

}
else
{
document.frmProperty.RearGarden.value = 0
}

return true

}

</script>

<%@ page import= "java.util.*" %>
<%@ page import= "java.text.*" %>
<%@ page import= "HousingManager.AgentsList" %>
<%@ page import= "HousingManager.Property" %>
<%@ page import= "HousingManager.PropertyRent" %>
<%@ page import= "HousingManager.PropertyFeature" %>
<%@ page import= "HousingManager.DateDropDownPopulator" %>
<%@ page import= "HousingManager.RefDataPopulator" %>
<jsp:useBean id="property" class="HousingManager.Property" scope="request"/>
<jsp:useBean id="rents" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="propertyFeatures" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="submitType" class="java.lang.String" scope="request"/>

<table width="95%" border="0" cellspacing="3" cellpadding="3" align="center">
<tr>
<td> <font face="Arial, Helvetica, sans-serif" size="2" color="#003366">
<b>Property Details
</b></font>
<br>
</td>
</tr>
<tr>
<td>
<br>
<%

//List featuresList = new LinkedList();
//List rentsList = new LinkedList();
//rentsList = (List)request.getAttribute("rents");
//featuresList = (List)request.getAttribute("propertyFeatures");

Integer varPropertyId = new Integer(0);
String varPropertyAddress = "";
String varPropertyArea = "";
String varPropertyArea2 = "";
String varPropertyTown = "";
String varPropertyCounty = "";
String varPropertyPostCode = "";
String varPropertyCountry = "";
Date varLeaseStart= new Date();
Date varLeaseEnd= new Date();
String varBreakClause = "";
String varPropertyTelephoneNo = "";
String varPropertyFaxNo = "";
Date varLeaseRenewal= new Date();
Float varDepositRequired = new Float(0);
String varDepositHeldBy = "";
Date varDepositReturned= new Date();
Integer varBedroom = new Integer(0);
Integer varBathroom = new Integer(0);
Integer varLavatory = new Integer(0);
Integer varKitchen = new Integer(0);
Integer varLounge = new Integer(0);
Integer varDiningRoom = new Integer(0);
Integer varReception = new Integer(0);
Integer varConservatory = new Integer(0);
Integer varShed = new Integer(0);
Integer varGarage = new Integer(0);
String varAccommodationType = "";
Integer varFrontGarden = new Integer(0);
Integer varFrontGardenSize = new Integer(0);
Integer varRearGarden = new Integer(0);
Integer varRearGardenSize = new Integer(0);
String varOtherPropertyInfo = "";
String varGeneralPropertyComments = "";
Integer varAgentId = new Integer(0);
Integer varNoticeDays = new Integer(0);
String varLetterOfGuarantee = "";
String varRentPaidTo = "";
String varAgentsHTMLStr = "";
String varFeaturesHTMLStr = "";
String varRentsHTMLStr = "";

HousingManager.Property aProperty =new HousingManager.Property();
aProperty = (HousingManager.Property)request.getAttribute("property");

String aSubmitType = (String)request.getAttribute("submitType");
if (submitType.equals(""))
{
aSubmitType = (String)request.getParameter("submitType");
}

if (aSubmitType.equals("SaveChanges"))
{
varPropertyId = aProperty.getPropertyId();
varPropertyAddress = aProperty.getPropertyAddress();
varPropertyArea = aProperty.getPropertyArea();
varPropertyArea2 = aProperty.getPropertyArea2();
varPropertyTown = aProperty.getPropertyTown();
varPropertyCounty = aProperty.getPropertyCounty();
varPropertyPostCode = aProperty.getPropertyPostCode();
varPropertyCountry = aProperty.getPropertyCountry();
varLeaseStart =aProperty.getLeaseStart();
varLeaseEnd = aProperty.getLeaseEnd();
varBreakClause = aProperty.getBreakClause();
varPropertyTelephoneNo = aProperty.getPropertyTelephoneNo();
varPropertyFaxNo = aProperty.getPropertyFaxNo();
varLeaseRenewal = aProperty.getLeaseRenewal();
varDepositRequired = aProperty.getDepositRequired();
varDepositHeldBy = aProperty.getDepositHeldBy();
varDepositReturned = aProperty.getDepositReturned();
varBedroom = aProperty.getBedroom();
varBathroom = aProperty.getBathroom();
varLavatory = aProperty.getLavatory();
varKitchen = aProperty.getKitchen();
varLounge = aProperty.getLounge();
varDiningRoom = aProperty.getDiningRoom();
varReception = aProperty.getReception();
varConservatory = aProperty.getConservatory();
varShed = aProperty.getShed();
varGarage = aProperty.getGarage();
varAccommodationType = aProperty.getAccommodationType();
varFrontGarden = aProperty.getFrontGarden();
varFrontGardenSize = aProperty.getFrontGardenSize();
varRearGarden = aProperty.getRearGarden();
varRearGardenSize = aProperty.getRearGardenSize();
varOtherPropertyInfo = aProperty.getOtherPropertyInfo();
varGeneralPropertyComments = aProperty.getGeneralPropertyComments();
varAgentId = aProperty.getAgentId();
varNoticeDays = aProperty.getNoticeDays();
varLetterOfGuarantee = aProperty.getLetterOfGuarantee();
varRentPaidTo = aProperty.getRentPaidTo();



}


Integer varPropertyFeaturesId = new Integer(0);
Integer varFeaturesPropertyId = new Integer(0);
String varFeatureName= "";


if(propertyFeatures.size()!=0)
{
ListIterator featuresIterator = propertyFeatures.listIterator();
varFeaturesHTMLStr = "<table width=95% cellSpacing=2 cellPadding=2>";
varFeaturesHTMLStr = varFeaturesHTMLStr+ " <tr><td bgColor=#D1E8E8><b>Property Features</b></td><td bgColor=#D1E8E8><b>Remove Feature</b></td></tr>";

while(featuresIterator.hasNext())
{
HousingManager.PropertyFeature featuresObj =new HousingManager.PropertyFeature();
featuresObj = (HousingManager.PropertyFeature)featuresIterator.next();
varPropertyFeaturesId=featuresObj.getPropertyFeaturesId();
varFeaturesPropertyId=featuresObj.getPropertyId();
varFeatureName=featuresObj.getFeatureName();
varFeaturesHTMLStr = varFeaturesHTMLStr+ "<tr>";
varFeaturesHTMLStr = varFeaturesHTMLStr + "<td bgColor=#ECECEC>" + varFeatureName +"</td>";
varFeaturesHTMLStr = varFeaturesHTMLStr + "<td bgColor=#ECECEC><a href=HousingManager.SetPropertyFeaturesServlet?PropertyFeaturesId=" + varPropertyFeaturesId +"&PropertyId="+ varFeaturesPropertyId+"&submitType=Delete&Name="+varFeatureName+" >Yes</a></td></tr>";
}

varFeaturesHTMLStr = varFeaturesHTMLStr + "</table>";
}


Integer varPropertyRentId = new Integer(0);
Integer varRentPropertyId = new Integer(0);
Date varStartDate= new Date();
Date varEndDate= new Date();
Float varAmount = new Float(0);


System.out.println("rents IN"+rents.size());
if(rents.size()!=0)
{
ListIterator rentsIterator = rents.listIterator();
varRentsHTMLStr = "<table width=95% cellSpacing=2 cellPadding=2>";
varRentsHTMLStr = varRentsHTMLStr+ " <tr><td bgColor=#D1E8E8><b>Start Date</b></td><td bgColor=#D1E8E8><b>End Date</b></td><td bgColor=#D1E8E8><b>Amount</b></td><td bgColor=#D1E8E8><b> Edit </b></td></tr>";

while(rentsIterator.hasNext())
{
HousingManager.PropertyRent rentsObj =new HousingManager.PropertyRent();
rentsObj = (HousingManager.PropertyRent)rentsIterator.next();
varPropertyRentId=rentsObj.getPropertyRentId();
varRentPropertyId=rentsObj.getPropertyId();
varStartDate=rentsObj.getStartDate();
varEndDate=rentsObj.getEndDate();
varAmount=rentsObj.getAmount();
varRentsHTMLStr = varRentsHTMLStr+ "<tr>";
varRentsHTMLStr = varRentsHTMLStr + "<td bgColor=#ECECEC>" + varStartDate +"</td><td bgColor=#ECECEC>"+varEndDate+"</td><td bgColor=#ECECEC>" + varAmount +"</td>";
varRentsHTMLStr = varRentsHTMLStr + "<td bgColor=#ECECEC><a href=HousingManager.ManagePropertyRent.jsp?PropertyRentId=" + varPropertyRentId +"&StartDate="+ varStartDate+"&EndDate="+ varEndDate+"&Amount="+ varAmount+">Yes</a></td></tr>";
varRentsHTMLStr = varRentsHTMLStr + "</table>";
}
varRentsHTMLStr = varRentsHTMLStr + "</table>";
}
List agentsList = new LinkedList();

HousingManager.AgentsList agentsListObj =new HousingManager.AgentsList();
agentsList = agentsListObj.getAgentsList();

Integer iAgentId = new Integer(0);
String sAgentName= "";
String sAgentTown= "";

ListIterator agentsIterator = agentsList.listIterator();
varAgentsHTMLStr = "<Select name=AgentId>";

while(agentsIterator.hasNext())
{
HousingManager.Agent agent =new HousingManager.Agent();
agent = (HousingManager.Agent)agentsIterator.next();
iAgentId = agent.getAgentId();
sAgentName = agent.getAgentName();
sAgentTown = agent.getAgentTown();

String selectedString="";
if(iAgentId.equals(varAgentId))
{
selectedString = " Selected";
}
varAgentsHTMLStr= varAgentsHTMLStr +" <option value='"+iAgentId+"'"+ selectedString+"> "+sAgentName+" - "+sAgentTown+" </Option>";
}
varAgentsHTMLStr = varAgentsHTMLStr+ "</Select>";

String varFrontGardenValue = "";
String varRearGardenValue = "";
Integer iChkBox = new Integer(1);
if(iChkBox.equals(varFrontGarden))
{
varFrontGardenValue = "checked";
}

if(iChkBox.equals(varRearGarden))
{
varRearGardenValue = "checked";
}


%>

<form name="frmProperty" action="/HousingManager/servlet/HousingManager.SetPropertyServlet" onSubmit='return ProcessForm()'>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr>
<td>
<input type="hidden" name="PropertyId" value="<%= varPropertyId %>">
<b>General Details</b></td>
<td>
</td>
</tr>

<tr>
<td>Property Address</td>
<td>
<input type="text" name="PropertyAddress" value="<%= varPropertyAddress %>">
</td>
</tr>
<tr>
<td>Property Area</td>
<td>
<input type="text" name="PropertyArea" value="<%= varPropertyArea %>">
</td>
</tr>
<tr>
<td>Property Area 2</td>
<td>
<input type="text" name="PropertyArea2" value="<%= varPropertyArea2 %>">
</td>
</tr>
<tr>
<td>Town</td>
<td>
<%
List townsList = new LinkedList();
HousingManager.RefDataPopulator townsRefData = new HousingManager.RefDataPopulator();
townsList = townsRefData.getData("Town", "Name", "");
out.println("<Select name=PropertyTown>");

String townsString="";

ListIterator townsIterator = townsList.listIterator();
while(townsIterator.hasNext())
{
townsString = (String)townsIterator.next();
String selectedString="";
if(townsString.equals(varPropertyTown))
{
selectedString = " Selected";
}
out.println("<option value='"+townsString+"'"+ selectedString+"> "+townsString+" </Option>");
}
out.println("</Select>");

%>

</td>
</tr>
<tr>
<td>County</td>
<td>
<%
List countyList = new LinkedList();
HousingManager.RefDataPopulator countyRefData = new HousingManager.RefDataPopulator();
countyList = countyRefData.getData("County", "Name", "");
out.println("<Select name=PropertyCounty>");

String countyString="";

ListIterator countyIterator = countyList.listIterator();
while(countyIterator.hasNext())
{
countyString = (String)countyIterator.next();
String selectedString="";
if(countyString.equals(varPropertyCounty))
{
selectedString = " Selected";
}
out.println("<option value='"+countyString+"'"+ selectedString+"> "+countyString+" </Option>");
}
out.println("</Select>");

%>
</td>
</tr>
<tr>
<td>Post Code</td>
<td>
<input type="text" name="PropertyPostCode" value="<%= varPropertyPostCode %>">
</td>
</tr>
<tr>
<td>Country</td>
<td>
<%
List countryList = new LinkedList();
HousingManager.RefDataPopulator countryRefData = new HousingManager.RefDataPopulator();
countryList = countryRefData.getData("Country", "Name", "");
out.println("<Select name=PropertyCountry>");

String countryString="";

ListIterator countryIterator = countryList.listIterator();
while(countryIterator.hasNext())
{
countryString = (String)countryIterator.next();
String selectedString="";
if(countryString.equals(varPropertyCountry))
{
selectedString = " Selected";
}
out.println("<option value='"+countryString+"'"+ selectedString+"> "+countryString+" </Option>");
}
out.println("</Select>");

%>
</td>
</tr>
<tr>
<td>Telephone Number</td>
<td>
<input type="text" name="PropertyTelephoneNo" value="<%= varPropertyTelephoneNo %>">
</td>
</tr>
<tr>
<td>Fax Number</td>
<td>
<input type="text" name="PropertyFaxNo" value="<%= varPropertyFaxNo %>">
</td>
</tr>
<tr>
<td>Agent Id</td>
<td>
<%
out.println(varAgentsHTMLStr);
%>
</td>
</tr>
<tr>
<td><br><b>Property Details</b></td>
<td>
</td>
</tr>
<tr>
<td>Accommodation Type</td>
<td>
<%
List accommodationTypeList = new LinkedList();
HousingManager.RefDataPopulator accommodationTypeRefData = new HousingManager.RefDataPopulator();
accommodationTypeList = accommodationTypeRefData.getData("PropertyTypes", "Name", "");
out.println("<Select name=AccommodationType>");

String accommodationTypeString="";

ListIterator accommodationTypeIterator = accommodationTypeList.listIterator();
while(accommodationTypeIterator.hasNext())
{
accommodationTypeString = (String)accommodationTypeIterator.next();
String selectedString="";
if(accommodationTypeString.equals(varAccommodationType))
{
selectedString = " Selected";
}
out.println("<option value='"+accommodationTypeString+"'"+ selectedString+"> "+accommodationTypeString+" </Option>");
}
out.println("</Select>");

%>
</td>
</tr>

<tr>
<td>Bedroom</td>
<td>
<input type="text" name="Bedroom" value="<%= varBedroom %>">
</td>
</tr>
<tr>
<td>Bathroom</td>
<td>
<input type="text" name="Bathroom" value="<%= varBathroom %>">
</td>
</tr>
<tr>
<td>Lavatory</td>
<td>
<input type="text" name="Lavatory" value="<%= varLavatory %>">
</td>
</tr>
<tr>
<td>Kitchen</td>
<td>
<input type="text" name="Kitchen" value="<%= varKitchen %>">
</td>
</tr>
<tr>
<td>Lounge</td>
<td>
<input type="text" name="Lounge" value="<%= varLounge %>">
</td>
</tr>
<tr>
<td>Dining Room</td>
<td>
<input type="text" name="DiningRoom" value="<%= varDiningRoom %>">
</td>
</tr>
<tr>
<td>Reception</td>
<td>
<input type="text" name="Reception" value="<%= varReception %>">
</td>
</tr>
<tr>
<td>Conservatory</td>
<td>
<input type="text" name="Conservatory" value="<%= varConservatory %>">
</td>
</tr>
<tr>
<td>Shed</td>
<td>
<input type="text" name="Shed" value="<%= varShed %>">
</td>
</tr>
<tr>
<td>Garage</td>
<td>
<input type="text" name="Garage" value="<%= varGarage %>">
</td>
</tr>
<tr>
<td>Front Garden</td>
<td>
<input type="checkbox" name="ChkBoxFrontGarden" value="ChkBoxFrontGarden" <%= varFrontGardenValue%>>
<input type="hidden" name="FrontGarden" value="0">
</td>
</tr>
<tr>
<td>Front Garden Size</td>
<td>
<input type="text" name="FrontGardenSize" value="<%= varFrontGardenSize %>">
</td>
</tr>
<tr>
<td>Rear Garden</td>
<td>
<input type="checkbox" name="ChkBoxRearGarden" value="ChkBoxRearGarden" <%= varRearGardenValue%>>
<input type="hidden" name="RearGarden" value="0">

</td>
</tr>
<tr>
<tr>
<td>Rear Garden Size</td>
<td>
<input type="text" name="RearGardenSize" value="<%= varRearGardenSize %>">
</td>
</tr>
<tr>
<tr>
<td>Other Property Info</td>
<td>
</td>
</tr>
<tr>
<td colspan=2>
<textarea name="OtherPropertyInfo" cols="54" rows="5" maxlength="255"><%= varOtherPropertyInfo %></textarea>
</td>
</tr>
</table>

</td>
<td width="50%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td><br><b>Rental Details</b></td>
<td>
</td>
</tr>
<tr>
<td>Lease Start Date</td>
<td>
<%

HousingManager.DateDropDownPopulator leaseStartObj =new HousingManager.DateDropDownPopulator();
String leaseStartStr = leaseStartObj.getDateString("LeaseStart",varLeaseStart);
out.println(leaseStartStr);

%>

<input type="hidden" name="LeaseStart" value="" maxlength="50">
</td>
</tr>
<tr>
<td>Lease End Date</td>
<td>
<%

HousingManager.DateDropDownPopulator leaseEndObj =new HousingManager.DateDropDownPopulator();
String leaseEndStr = leaseEndObj.getDateString("LeaseEnd",varLeaseEnd);
out.println(leaseEndStr);

%>

<input type="hidden" name="LeaseEnd" value="" maxlength="50">
</td>
</tr>
<tr>
<td>Break Clause</td>
<td>
</td>
</tr>
<tr>
<td colspan=2>
<textarea name="BreakClause" cols="54" rows="5" maxlength="255"><%= varBreakClause %></textarea>
</td>
</tr>
<tr>
<td>Lease Renwal Date</td>
<td>
<%

HousingManager.DateDropDownPopulator leaseRenewalObj =new HousingManager.DateDropDownPopulator();
String leaseRenewalStr = leaseRenewalObj.getDateString("LeaseRenewal",varLeaseRenewal);
out.println(leaseRenewalStr);

%>

<input type="hidden" name="LeaseRenewal" value="" maxlength="50">
</td>
</tr>
<tr>
<td>Deposit Required</td>
<td>
<input type="text" name="DepositRequired" value="<%= varDepositRequired %>">
</td>
</tr>
<tr>
<td>Deposit Held By</td>
<td>
<%
List depositHeldByList = new LinkedList();
HousingManager.RefDataPopulator depositHeldByRefData = new HousingManager.RefDataPopulator();
depositHeldByList = depositHeldByRefData.getData("DepositHolders", "Name", "");
out.println("<Select name=DepositHeldBy>");

String depositHeldByString="";

ListIterator depositHeldByIterator = depositHeldByList.listIterator();
while(depositHeldByIterator.hasNext())
{
depositHeldByString = (String)depositHeldByIterator.next();
String selectedString="";
if(depositHeldByString.equals(varDepositHeldBy))
{
selectedString = " Selected";
}
out.println("<option value='"+depositHeldByString+"'"+ selectedString+"> "+depositHeldByString+" </Option>");
}
out.println("</Select>");

%>

</td>
</tr>
<tr>
<td>Deposit Returned Date</td>
<td>
<%

HousingManager.DateDropDownPopulator depositReturnedObj =new HousingManager.DateDropDownPopulator();
String depositReturnedStr = depositReturnedObj.getDateString("DepositReturned",varDepositReturned);
out.println(depositReturnedStr);

%>

<input type="hidden" name="DepositReturned" value="" maxlength="50">

</td>
</tr>

<tr>
<td>Notice Days</td>
<td>
<input type="text" name="NoticeDays" value="<%= varNoticeDays %>">
</td>
</tr>
<tr>
<tr>
<td>Letter Of Guarantee</td>
<td>
<Select name=LetterOfGuarantee>;
<%
if (varLetterOfGuarantee.equals("Yes"))
{
out.println("<option value='Yes' selected>Yes</Option>");
out.println("<option value='No' >No</Option>");
}
else
{
out.println("<option value='Yes' >Yes</Option>");
out.println("<option value='No' selected>No</Option>");
}
%>
</Select>

</td>
</tr>
<tr>
<td>Rent Paid To</td>
<td>
<input type="text" name="RentPaidTo" value="<%= varRentPaidTo %>">
</td>
</tr>
<tr>
<td>General Property Comments</td>
<td>
</td>
</tr>
<tr>
<td colspan=2>
<textarea name="GeneralPropertyComments" cols="54" rows="5" maxlength="255"><%= varGeneralPropertyComments %></textarea>
</td>
</tr>
</table>
<br>
<%

if (aSubmitType.equals("Save"))
{
out.println("<input class=button type=reset name=reset value=Clear>");
out.println("<input class=button type=submit name=PropertyButton value=Save>");
}
else if(aSubmitType.equals("SaveChanges"))
{
out.println("<input class=button type=submit name=PropertyButton value=Delete>");
out.println("<input class=button type=submit name=PropertyButton value=SaveChanges>");
}

%>
<br>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td >
<%
out.println(varFeaturesHTMLStr);
%>
</td>
</tr>
</table>
<br>
<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td >
<%
out.println(varRentsHTMLStr);
%>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>

</table>
</td>
<td width="175" bgcolor="#D1E8E8" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr align="center">
<td>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><b>Date</b></font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2">jsp
code here<br>
</font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><b>Logged
In As</b></font></td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2">jsp
code here</font></td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td><font face="Arial, Helvetica, sans-serif" size="2"></font></td>
</tr>
<tr align="center">
<td>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<%
if(aSubmitType.equals("SaveChanges"))
{
%>

<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2" color="#003366">
<a href="/HousingManager/MaintainProperty.jsp?submitType=Save&properties=[]">
<b>Add New Property</b>
</a>
</font></td>
</tr>
<% } %>

<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td></td>
</tr>
<tr>
<td>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<%
if(aSubmitType.equals("SaveChanges"))
{
out.println("<tr><td><a href=/HousingManager/ManagePropertyRent.jsp?PropertyRentId=0&StartDate=&EndDate=&Amount=0.00&PropertyId="+varPropertyId+">");
out.println("<b>Add New Rent</b></a></td></tr>");
}
%>

<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td></td>
</tr>
<tr>
<td>
<table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<%
if(aSubmitType.equals("SaveChanges"))
{
out.println("<tr><td><a href=/HousingManager/AddPropertyFeature.jsp?PropertyId="+varPropertyId+">");
out.println("<b>Add New Property Feature</b></a></td></tr>");
}
%>

<tr>
<td> </td>
</tr>
</table>
</td>
</tr>

<tr>
<td></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<%@ include file="bottom.htm" %>
Steve Leach
Ranch Hand

Joined: Sep 24, 2003
Posts: 46
In the servlet you are using dbCon.getDBResultSet() multiple times. Are you sure that the results from the first call are still available after the second call ?
Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
Hi guys
I have fixed the problem now. It was in Class DBConnection where I had the LinkedList which returned a list declared as public static outside the getDBResultSet method.
So once a particular type of object is inserted into the list second time around it just took the object type to be same as before.
Now i am declaring the Linked list inside getDBResultSet method. Thanks for your help ...
cheers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing more than one object between jsp and servlet