Ajax/JSP problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nenad_Bosanac
Posted On:   Monday, April 17, 2006 11:16 AM

Address Form clearList(list); if (items.length > 0) { for (var i = 0; i < items.length; i++) { var node = items[i]; var value = ""; var label = ""; if (node.getElementsByTagName("label")[0].firstChild.nodeValue) { value = node.getElementsByTagName("label")[0].firstChild.nodeValue; label = node.getElementsByTagName("value")[0].firstChild.nodeValue; } addElementToList(list, value, label); } } else { addElementToList(list, "", "-- Select is Empty --"); } } /** remove the content of te list */ func   More>>
Address Form clearList(list);
if (items.length > 0)
{
for (var i = 0; i < items.length; i++)
{
var node = items[i];
var value = "";
var label = "";
if (node.getElementsByTagName("label")[0].firstChild.nodeValue) {
value = node.getElementsByTagName("label")[0].firstChild.nodeValue;
label = node.getElementsByTagName("value")[0].firstChild.nodeValue;
}
addElementToList(list, value, label);
}
}
else
{
addElementToList(list, "", "-- Select is Empty --");
}
}

/**
remove the content of te list
*/
function clearList(list)
{
while (list.length > 0)
{
list.remove(0);
}
}

/**
Add a new element to a selection list
*/
function addElementToList(list, value, label)
{
var option = document.createElement("option");
option.value = value;
var labelNode = document.createTextNode(label);
option.appendChild(labelNode);
list.appendChild(option);
}



]]>

Hi to everyone!


I have problem with AJAX.I will to try my problem in short.
I tried to make some JSP page with ajax help.
This code make some list box and then put in it some countries when someone choose circle I,II or III.
Everything works fine with code except one thing.I cant see
countries in my listbox.All i can see is --Select is empty -- thing.
Why is that?Can anyone can help me?
Thanks!


Here is my code>




ajaxOptions.jsp















Address Form





















Address

Apt#

State



City

Zip














division.jsp




<%@ page import="java.sql.*" %>
<%
//String Par = request.getParameter("Circle");
Integer regionID=new Integer(request.getParameter("Circle").trim());
out.write("region ID je:"+regionID);
Connection conn = null;
try {
/* Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.0.2:1521:orcl",
"scott",
"tiger");*/
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test1","root", "boske");
PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM country where (Region_ID="+regionID+")");
//String q = new String();
//q="SELECT * FROM country WHERE Region_ID= "+Par;
out.write("konekcija prosla");
//ResultSet rs = stmt.executeQuery(q);
ResultSet rs = pstmt.executeQuery();
StringBuffer buffer = new StringBuffer();
buffer.append(" <?xml version="1.0" encoding="UTF-8"?>");
buffer.append("
");
buffer.append(" ");
buffer.append("
");
out.write("pre popunjavanja");
while(rs.next()) {

buffer.append(" ");
buffer.append("
");
buffer.append(" ");
buffer.append("
");
buffer.append(" "+ rs.getString("Country_name")+" ");
buffer.append("
");
buffer.append(" ");

}
buffer.append("
");
buffer.append(" ");
System.out.print(buffer.toString());
response.addHeader("Content-Type", "text/xml");
response.setContentType("text/xml; charset=UTF-8");
out.write(buffer.toString());

} catch(SQLException e) {
out.println("SQLException: " + e.getMessage() + "
");
while((e = e.getNextException()) != null)
out.println(e.getMessage() + "
");
} catch(ClassNotFoundException e) {
out.println("ClassNotFoundException: " + e.getMessage() + "
");
} finally {
//Clean up resources, close the connection.
if(conn != null) {
try {
conn.close();
} catch (Exception ignored) {}
}
}


%>

   <<Less

Re: Ajax/JSP problem

Posted By:   Nenad_Bosanac  
Posted On:   Sunday, April 30, 2006 11:41 AM

i find solution for my problem .Thanks
Who is interesting in that please ask.
About | Sitemap | Contact