2

I wanted to know if there is any way of creating a servlet-mapping which can be only accessed within the webapplication. For example a file inside this application calls another file but it sould not be accessable from outside the web-app.

Thank You,

3
  • Where have you placed your web files? If you place them in web-inf folder, it will not be accessible to outside world. Commented Jul 24, 2012 at 18:00
  • 1
    what ever the mapping you have done in web.xml is global, so I don't think you can restrict like you have asked. One way may be write a Filter which checks for request headers (or) certain parameter to differentiate browser call (or) internal call then decide whether to forward to servlet (or) return to error page. Commented Jul 24, 2012 at 18:05
  • Thanks for the filter advise. I have implemented that and works fine. Commented Jul 25, 2012 at 21:41

1 Answer 1

2

yes there is a way. Placing your restricted jsp files inside your web-inf directory. Then importing those jsp's in other jsp's is perfectly legal and wont cause you any problem.

see an example jsp below:

<%@page import="admin.*"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<tiles:insert template='myTemplate.jsp'>
  <tiles:put name='top' content='/WEB-INF/templates/top.jsp''/>  
  <tiles:put name='main' content='/WEB-INF/templates/main.jsp''/>  
  <tiles:put name='footer' content='/WEB-INF/templates/footer.jsp'/>
</tiles:insert>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.