File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Two URL's for every action in my struts project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Two URL Watch "Two URL New topic
Author

Two URL's for every action in my struts project

Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Hi All,

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.

Thanks:
Ramakrishna K.C
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
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.


Ping & DNS - my free Android networking tools app
Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Thanks for reply,

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?



Thanks:
Ramakrishna K.C
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
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.
Ramakrishna Udupa
Ranch Hand

Joined: Aug 09, 2013
Posts: 253
Thanks Ulf Dittmer. Thanks a lot.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8907
    
    8

Ramakrishna Udupa wrote:Thanks for reply,
In net I got this code. But, don't know the what it'll do. Can you Explain me please?


This is the standard JEE security mechanism built into the container. See the tutorial for details.
I like Ulf's solution. Simple and effective.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Two URL's for every action in my struts project