Tuesday, June 2, 2009

ASP Respose.Redirect to JSP jsession

Well this starts my first ever blog, I've searched and used many such articles and find that it is high time to start giving back. Hope it's helpful to someone.

Today I found my self trying to link a legacy ASP web application to a J2EE web application. The idea was simple, take a request from the ASP page, formulate an XML request to the J2EE app for authentication, receive back the url from the J2EE app where to forward the user to complete the task. Pretty straight forward and simple ASP/VBScript until it came time to redirect the user.

Searching for how to Redirect in ASP one finds many articles on Response.Redirect ("url")

However, in my case the url looked something like:
http://my.servername.com:9999;jsessionid=skskdlrickdrfjfkwesf!20090624?myid=123456

When you push this through Response.Redirect it encodes the ";","="and "!" before the querystring thus you get something like:
http://my.servername.com:9999%3Bjsessionid%3Dskskdlrickdrfjfkwesf%2120090624?myid=123456

This doesn't play well on the J2EE server and hence you don't get to where you want to be.

Solution:

Take matters into your own hands with the HTTP Headers:

Response.Status = "302 Object moved"
Response.AddHeader "Location", Url
Response.End


The hint that was very helpful to me came from http://www.somacon.com/p145.php

Hope this helps.

No comments:

Post a Comment