开发者

How to use request.getHeader("Referer")

In my current project, I have a shopping cart integrated with the main site. Now I have to create some mini sites to display the data retrieved from main site. When the user click buy now button in mini site, it should redirect to the main shopping cart. But when user click the Continue shopping button, that should be send back to the mini site page where he was browsing. Both sites will be in 2 different domain names. Can I send him back to the page where he was browsing us?

request.getHeader("Referer")

This will be 2 differe开发者_开发知识库nt web apps so will the request.getHeader("Referer") help to send him back to the page where he was browsing.

Please send me some suggestions.


You shouldn't rely on Referer for the logic of your application, since sending Referer can be blocked by firewalls or browser configuration.

Consider passing return URL as a parameter instead: http://mainsite.com/shoppingCart?returnTo=http%3a%2f%2fminisite.com%2foriginalPage.

Also make sure that returnTo points to your site to avoid possible security problems.


this seems to be the correct syntax:

getHttpServletRequest().getHeader("Referer"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜