Results 1 to 2 of 2

Thread: Cant call a servlet from ExtJs controller

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    13
    Vote Rating
    0
      0  

    Default Cant call a servlet from ExtJs controller

    i have a controller in extjs application, from where i have to call a servlet. But i am unable to call that servlet from controller here is my controller code ..... when i am running the application always failure part is showing "server-side failure with status code" this is the problem:

    Ext.define('Gamma.controller.ControlFile', {extend : 'Ext.app.Controller',//define the storesstores : ['BarColumn', 'RadarView', 'VoiceCallStore', 'SMSCallStore', 'MMSCallStore', 'GPRSUsageStore'],//define the models models : ['BarCol', 'radar', 'VoiceCallModel', 'SMSCallModel', 'MMSCallModel', 'GPRSUsageModel'],//define the viewsviews : ['BarColumnChart', 'LineChart', 'RadarChart', 'VoicePie', 'SMSPie', 'MMSPie', 'GPRSPie'],initializedEvents: false,init: function() { this.control({ '#barColumnChart': { afterlayout: this.afterChartLayout } });},afterChartLayout: function(){ var me=this; if(this.initializedEvents==true) return; this.initializedEvents=true; Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){ // alert(obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']); var barData=obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']; me.dataBaseCall(obj.storeItem.data['source'],obj.storeItem.data['count']); });},dataBaseCall: function(source,count){ //alert(barData); Ext.Ajax.request({ url: "CallRatiosAnalysis", success: function(response, opts){ //do what you want with the response here console.log("hiiiiiiiiiiii"); }, failure: function(response, opts) { alert("server-side failure with status code " + response.status); }, params: { source: source, count: count } }); }});and this is my Servlet:

    public class CallRatiosAnalysis extends HttpServlet {
    @Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response);}@Overrideprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String start = request.getParameter("start"); String limit = request.getParameter("limit"); PrintWriter out = response.getWriter(); response.setContentType("text/html"); ArrayList<IndCallType> ratios = new ArrayList<IndCallType>(); ratios.add(new IndCallType("Voice", "40")); ratios.add(new IndCallType("SMS", "30")); ratios.add(new IndCallType("MMS", "5")); ratios.add(new IndCallType("GPRS", "20")); ratios.add(new IndCallType("Others", "5")); Gson gson = new Gson(); JsonArray arrayObj = new JsonArray(); for (int i = 0; i < ratios.size(); i++) { IndCallType count = ratios.get(i); JsonElement linObj = gson.toJsonTree(count); arrayObj.add(linObj); } JsonObject myObj = new JsonObject(); myObj.addProperty("success", true); myObj.add("allCalls", arrayObj); myObj.addProperty("allCallsRatio", ratios.size()); out.println(myObj.toString()); out.close();}}

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    Your url in Ext.Ajax.request() should be an http served url (either direct or relative), not a method defined in script on your server.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •