In Struts-2 Web-App, I defined lot of JSP's under my WebContent folder. I specified Action for required JSP's. Now I got Two URL's. I mean,
When Action executes, It shows JSP page with URL as
When I replace this URL by
It shows same Page obviously. I want to restrict the URL which contains .JSP as extension. So please tell me the best practices to avoid two URL's for same page.
Also, I know the concept of namespaces. But, Simply by going in struts.xml and giving namespace with some name will not work. For that should I create the folder of JSP's in my WebContent? Please forward me a good article about namespaces.
The best approach is to make access to JSP pages directly (without going through Struts) impossible by moving the JSP pages into a non-public directory. A subdirectory of WEB-INF is commonly used for this purpose.
So, If I create directory in WebContent folder and moving those JSP's into that folder, solve this problem ? Is there any method to block .JSP itself in my project ? In net I got this code. But, don't know the what it'll do. Can you Explain me please?
Joined: Mar 22, 2005
Not "WebContent" -whatever that is- but "WEB-INF". And you don't need to do anything in the web.xml file (in other words, delete what you posted) - nothing that is inside of WEB-INF will ever be served directly to the client.