Expand my Community achievements bar.

SOLVED

Weird error that only happens when GET or POST through IE9

Avatar

Level 2

Hello,

Want to share with you some back-end code that should work, but doesn't, on IE9. This has nothing to do with any FE code, but backend servlet code.

@SlingServlet(             paths={"/apps/my-app/check"},                     methods = { "GET", "POST" },                             name="com.my-app.test.TestServlet"                                 )                                 @Properties({                                         @Property(name = "service.pid", value = "Some Name", propertyPrivate = false),                                             @Property(name = "service.description", value = "Some service description", propertyPrivate = false),                                                 @Property(name = "service.vendor", value = "Some vendor", propertyPrivate = false)                                 })                                                                 public class TestServlet extends SlingAllMethodsServlet  {                                                                                     @Override                                                 protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {                                                                                                                                 response.getWriter().write("GET");                                                                                                                                                                 Resource r = request.getResourceResolver().getResource("/apps/my-app/repo/");                                                                                     //This is a valid node                                                                                                                                                                                                 if (r == null)                                                                                                             {                                                                                                                          response.getWriter().write("r is null");                                                                                                             }else{                                                                                                                          response.getWriter().write("r is not null");                                                                                                             }                                                                                                                                                                 }                                                                                  @Override                                                         protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {                                                                                                                                 response.getWriter().write("POST");                                                                                                                                                                 Resource r = request.getResourceResolver().getResource("/apps/my-app/repo/");                                                                                                                                                                                                 if (r == null)                                                                                                             {                                                                                                                          response.getWriter().write("r is null");                                                                                                             }else{                                                                                                                          response.getWriter().write("r is not null");                                                                                                             }                                                                                                                                                                             }                                 }                                 

Using FF if I POST or GET to /apps/my-app/check, I get "r is not null". However in IE, I get "r is null". The only thing that is different is that the browser that the request was sent.

This doesn't happen in my local author server, but only on the Dev Server. I am accessing the Dev Pub via IP and not via dispatcher.

 

Any ideas on why this happens?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

Please compare the raw requests and the raw responses you get with the 2 browsers; on Firefox you can use Firebug, IE should have something similar.

As recommended change I would first set a mime-type (e.g. "text/plain") to your response. I know, that IE is a bit picky in that area.

kind regards,
Jörg

View solution in original post

3 Replies

Avatar

Level 10

I am going to test this tomorrow - I know that IE 9 is a bad browser (I personally never use it) - but I want to test this and see if I get this result.

Update - check this out: http://stackoverflow.com/questions/25405998/ie9-compatibility-jquery-ajax-post-request 

Avatar

Correct answer by
Employee Advisor

Hi,

Please compare the raw requests and the raw responses you get with the 2 browsers; on Firefox you can use Firebug, IE should have something similar.

As recommended change I would first set a mime-type (e.g. "text/plain") to your response. I know, that IE is a bit picky in that area.

kind regards,
Jörg

Avatar

Level 2

The thing is, there is nothing that is processed from the request from IE. The only thing that we get from the request is the ResourceResolver. I did a check to see if that was null, and it wasn't.

This is not reproducible via my local author env, but only happens on the Dev env.

smacdonald2008 wrote...

I am going to test this tomorrow - I know that IE 9 is a bad browser (I personally never use it) - but I want to test this and see if I get this result.

Update - check this out: http://stackoverflow.com/questions/25405998/ie9-compatibility-jquery-ajax-post-request