user1665700
user1665700

Reputation: 512

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?

Upvotes: 1

Views: 548

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340733

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.

Upvotes: 2

Related Questions