Friday, May 15, 2015

window.location.href is not working while clicking on hyper link in IE

window.location.href is not working while clicking on hyper link  in IE

I was trying to redirect to a page while clicking on a hyper link with JQuery Ajax and java script windows.location.href

<a id="signout" href="">signOut<a/>

<script>
    $("#signout").click(function(){

                       $.ajax({
                        type : "POST",
                        async: false,
                        url : "/services/logout",                    
                        success : function() {
                                       window.location="/content/test/test.html";
 },
error : function() {
                                       window.location="/content/test/test.html";
}
});
    } );
</script>

This is working perfectly in both Firefox and Chrome but it is not working in IE.

In IE while redirecting the URL is stripped off to /content/test/(test.html got removed while performing the redirect)

The issue can be fixed as below by adding # in href attribute.

<a id="signout" href="#">signOut<a/>



Tuesday, April 7, 2015

How to enable SSH X11 forwarding in Linux?

How to enable SSH X11 forwarding in Linux?

The  X11 forwarding from putty using Xming was not working, the DISPLAY variable is not set(echo $DISPLAY) after opening the remote server session in putty(X11 forwarding is enabled in putty and also the display is specified as localhost:0.0)

The actual issue is the X11 forwarding was not enabled in remote linux server.

The following steps can be followed to enable the X11 forwarding in linux server.

Login to linux server through putty

vi /etc/ssh/sshd_config

Enable the following flags

AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes

Execute the following commands

service sshd restart

yum -y update xauth
yum -y install xauth

Now you will be able to perform X11 forwarding.



Tuesday, February 10, 2015

Expected a string but was BEGIN_ARRAY at line 1 column - Gson

Expected a string but was BEGIN_ARRAY at line 1 column 

I was receiving "Expected a string but was BEGIN_ARRAY at line 1 column" error while deserializing the json string to java object using Gson.

Model class:

public class EmailGroup{
private String type;
private String id;
private String name;
private String permissions;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPermissions() {
return permissions;
}
public void setPermissions(String permissions) {
this.permissions = permissions;
}
}

JSON Response:

{"emailGroup":{"type":"EmailGroup","id":"1","depth":"minimal","description":"","name":"sample","permissions":[2,5,4,3]}}

Gson gson = new Gson();
EmailGroup obj = gson.fromJson(jsonstring, EmailGroup.class)

The root cause of the exception is the permissions attribute defined in the model class is of type String but the type of permissions in the jsonstring is List.

To fix the issue convert the type of permissions in the model class to List<String>(type string will change based on the type of the list entries)

public class EmailGroup{
private String type;
private String id;
private String name;
private List<String> permissions;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(List<String> permissions) {
this.permissions = permissions;
}
}



Saturday, January 31, 2015

Accessing static files through Apache HTTP Server in Linux

Accessing static files through Apache HTTP Server in Linux

This post will explain accessing static files through Apache HTTP Server in Linux

Create  a folder in server to store the static files  e.g. /app/apache/static/

Copy all the static files to /app/apache/static/ folder

Add the below contents to httpd.conf file

##Grant the access to unix user that will access the static folder
<IfModule unixd_module>
      User apacheuser
      Group apacheuser
</IfModule>

DirectoryIndex index.htm index.html

ErrorDocument 400 /error.html
ErrorDocument 401 /error.html
ErrorDocument 403 /error.html
ErrorDocument 404 /error.html
ErrorDocument 405 /error.html
ErrorDocument 408 /error.html
ErrorDocument 414 /error.html
ErrorDocument 500 /error.html
ErrorDocument 502 /error.html
ErrorDocument 504 /error.html

<VirtualHost *:80>
  ServerName staticfiles.com:80
  DocumentRoot /app/apache/static/

 Alias /files  "/app/apache/static"

<Directory /app/apache/static>
    Order deny,allow
    Allow from all
    SetHandler default-handler
</Directory>
</VirtualHost>

Now we can access the static file with the following url - http://staticfiles.com/files/<<file name>>

The Apache server referred here is 2.2.15


403 Forbidden/403 XSRF Protection Failure error while invoking Eloqua Send mail API

403 Forbidden/403 XSRF Protection Failure error while invoking Eloqua Send mail API

We will be receiving 403 Forbidden/ 403 XSRF Protection Failure error while invoking the Eloqua Send mail API - /api/rest/1.0/assets/email/deployment

Verify whether the user has the role "Engage Users", if not add the "Engage Users" security group to the user and Save the changes.


If the Engage Users role is already added then clear the browser cookies and try again.