问题描述:

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.

相关阅读:
Top