aspose file tools*
The moose likes Struts and the fly likes How to use Servlet Filter in Struts Framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use Servlet Filter in Struts Framework" Watch "How to use Servlet Filter in Struts Framework" New topic
Author

How to use Servlet Filter in Struts Framework

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
I am developing a web application with Struts 1.3.10.
I have placed all the jsp files inside the WEB-INF folder.
Then only realised the problem of not able to access it directly.
So I have decided to move it outside the WEB-INF and but still I want the jsp not to be accessed directly.
So I have decided to use Servlet Filter to restrict it and can use it for security purpose also.

Now I have two questions:

1. Placing the jsp files outside the WEB-INF folder:

How to implement the Filter with Struts?

I have written a sample filter and configured it in web.xml



web.xml


When I am invoking the below url: http://127.0.0.1:8080/Struts/reg.do, filter is not invoking and it goes to the actionservlet alone.
Whether any specific configuration setting is there for using Filter in Struts?

2. Placing the jsp files inside the WEB-INF folder:

I know we can't directly access the jsp files. But through the servlet we can get it. If suppose I am keeping the jsp files of header.jsp, footer.jsp and menu.jsp and I am trying to use frame for it. How can we get those pages?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you don't want to be able to access the JSP files directly then why move them out of WEB-INF?!
Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
David Newton wrote:If you don't want to be able to access the JSP files directly then why move them out of WEB-INF?!


Ok. Then please suggest me how to access the jsp files inside the WEB-INF folder?
Tell me how to refer the jsp page in the following?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh; if you're going to access *some* files outside of the framework then you'll either have to move those particular ones out of WEB-INF or access them via an action. You could also use a mechanism that loads those pages from the server side, like Tiles.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to use Servlet Filter in Struts Framework