please need help how to send XML data from servlet to EXTjs?
843842May 5 2010 — edited May 10 2010hi i am new to java web language and EXTjs i see a tutorial that used java as server side and Oracle XE to store the data.i changed to mysql .i am using netbeans IDE 6.8
_//this some of the application js file_
_//save button_
var saveButtonHandler = function() {
createForm.form.submit({url:'FormAction', waitMsg:'Saving Data...',success:doneFunction});
}
_//and here to read data_
ds = new Ext.data.Store({
url:'ReadToList',
reader: new Ext.data.XmlReader({record:'record'},
['name','age','city','phone'])
});
the save button work fine and the data is stored on my database but when i click to read data in datagrid nothing appear this the servlet readtolist.java
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ReadToList extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
public ReadToList() {
super();
}
protected void process(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException {
try {
ServletOutputStream sos = response.getOutputStream();
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setContentType("text/xml");
String query="SELECT *FROM ext";*
GestionBD gbd = new GestionBD();
gbd.connecter();
Statement st= gbd.connecter().createStatement();
ResultSet rs = st.executeQuery(query);
sos.println("<dataset>");
*while(rs.next()) {*
sos.println("<record>");
*sos.println("<name>" rs.getString("name") "</name>");*
*sos.println("<age>" rs.getString("age") "</age>");*
*sos.println("<city>" rs.getString("city") "</city>");*
*sos.println("<phone>" rs.getString("phone") "</phone>");*
sos.println("</record>");
*}*
sos.println("</dataset>");
rs.close();
sos.close();
*} catch (IOException e) {*
*// TODO Auto-generated catch block*
e.printStackTrace();
*} catch (SQLException e) {*
*// TODO Auto-generated catch block*
e.printStackTrace();
*}*
*}*
*protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {*
*try {*
process(request, response);
*} catch (ClassNotFoundException ex) {*
Logger.getLogger(ReadToList.class.getName()).log(Level.SEVERE, null, ex);
*}*
*}*
*protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {*
*try {*
process(request, response);
*} catch (ClassNotFoundException ex) {*
Logger.getLogger(ReadToList.class.getName()).log(Level.SEVERE, null, ex);
*}*
*}*
*}*
i called the js file in jsp page .
i want to find the problem ,when i click read the action work but nothing appear maybe the problem in the servlet to send XML data to read in the JS file .
please need ur help cause i need it on my project for study and thanks .