View Full Version : Reading HTML response from a Servlet

13 Aug 2011, 1:24 PM
Hey guys,
I'm new to the Ext Js 4, I've spent the last week reading all the tutorials of the Learn link up there.
Then, yesterday I started my first real application, what I need to do is to login in a server using a Servlet that is already done (and I can't change it or do it in another way). My problem is that the callback of the submit action is trying to convert the response as JSON but it is HTML.
I call a Servlet passing User and Password, if the authentication is right i get this html return:

<script type="text/javascript" language="JavaScript1.2" src="wfr.js?hash=4dd25a770030869a54bb493d33869bee"></script><script type="text/javascript" language="JavaScript1.2"><!--window.location = 'logon.jsp?sys=VMS&msgKey=C11F2356-C55F-4CCC-A4A6-895E5E0B2563';//--></script>

If the authentication fails, I get this message:

<script type="text/javascript" language="JavaScript1.2"> window.location = 'open.do?sys=VMS'; </script>

All I need to know is to search for the substring 'open.do?' in the answer to know if the authentication get wrong (I know it is very ugly, but I can't do it other way ... )

This is my code:

var form = button.up('form').getForm(),
sys = form.findField('sys').getValue();

if (form.isValid()) {
url: '',
waitMsg: 'Aguardando resposta do webrun...',
waitTitle: 'Fazendo logon',
timeout: 60,
success: function(form, action) {
//Ext.MessageBox.alert('Sucess', action.result.msg);
failure: function(form, action) {
//Ext.MessageBox.alert('Failed', action.result.msg);

This is the message I get when I run it:

Uncaught Ext.Error: You're trying to decode an invalid JSON String: <script type="text/javascript" language="JavaScript1.2"> window.location = 'open.do?sys=VMS'; </script>

Any suggestions?


14 Aug 2011, 4:41 AM
I've just tried to set the form's reader config to this:

reader : new Ext.data.reader.Xml({
record: 'script'

But with no success, it still gives me the same error message ...

Uncaught Ext.Error: You're trying to decode an invalid JSON String: <script type="text/javascript" language="JavaScript1.2">window.location = 'open.do?sys=VMS';</script><!-- Tempo de Carga: 8ms -->

Please, help ...