当前位置: 动力学知识库 > 问答 > 编程问答 >

java - How to restrict access to a Servlet via browser

问题描述:

I'm using the following jquery codes to load a Servlet inside a DIV.

$.get('Test',function(responseText){

$("#test").html(responseText);

});

The elements brought from this Servlet will use the css file including in this webpage.

But if I type in my browser ..../myProject/Test

It will display what this Servlet is meant to display, but with no css file, it will look bad.

How to restrict someone from accessing this Servlet via browser?

网友答案:

First of all, when you are fetching something using AJAX, you are accessing it via browser.

You can set some special HTTP header in AJAX call, but it's not secure by any means. However on the server side you can recognize this special header and if not present, refuse or return some different content.

分享给朋友:
您可能感兴趣的文章:
随机阅读: