开发者

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 开发者_C百科easiest way to do that?


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜