View Full Version : Can't get servlet to be invoked by extjs javascript code

1 Aug 2011, 1:23 PM

I have a webapp using java, extjs deployed in Tomcat. I am trying to call a servlet from a js. I can call the servlet directly and it comes up. But extjs cannot. Please help!!



This file is part of Ext JS 4

Copyright (c) 2011 Sencha Inc

Contact: http://www.sencha.com/contact

GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.

If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.


Ext.onReady(function() {
var form = Ext.create('Ext.form.Panel', {
layout: 'absolute',
url: 'test3',
defaultType: 'textfield',
border: false,

items: [{
fieldLabel: 'Send To',
fieldWidth: 60,
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 5,
name: 'to',
anchor: '-5' // anchor width by percentage
}, {
fieldLabel: 'Subject',
fieldWidth: 60,
x: 5,
y: 35,
name: 'subject',
anchor: '-5' // anchor width by percentage
}, {
y: 65,
xtype: 'textarea',
style: 'margin:0',
hideLabel: true,
name: 'msg',
anchor: '-5 -5' // anchor width and height

var win = Ext.create('Ext.window.Window', {
title: 'Resize Me',
width: 500,
height: 300,
minWidth: 300,
minHeight: 200,
layout: 'fit',
items: form,

buttons: [{
text: 'Reset',
handler: function() {
}, {
text: 'Submit',
handler: function() {
Ext.MessageBox.alert('Submitted Values', 'Submitted Values');





<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

I can bring up the servlet with: http://localhost:8080/TestExtJs/test3

But in index.js (shown above), I have

url: 'test3',

and in the button handler for the submit button, I have:


Shouldn't this submit the form and call test3?

Please help...I must be overlooking something simple!

Thanks in advance.

8 Aug 2011, 6:02 AM
This has been solved. I simplified the code and it worked just as the examples showed.

13 Aug 2011, 5:04 PM
Do you get some response from that servlet?

I started another thread about something like this, in my case I'm trying to read the response in HTML not in JSON, which seems to be the standard ...