wasimbhalli
wasimbhalli

Reputation: 5242

How to disable specific parts of an application in jsf?

I have a JSF application in which I have different servlets and facelets. The server is on real IP. Now what I want is that, one servlet be accessible from anywhere online, rest of the application should be only accessible via localhost? What's the easiest way to do that?

Upvotes: 3

Views: 100

Answers (1)

BalusC
BalusC

Reputation: 1108802

Use a Filter which is mapped on an url-pattern covering the resources you'd like to hide and does basically as follows in doFilter() method:

if (request.getRemoteAddr().equals(request.getLocalAddr())) {
    chain.doFilter(request, response);
} else {
    ((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
}

It'll show a HTTP 403 FORBIDDEN error for requests not originated by same client as where the server runs.

Upvotes: 5

Related Questions