aspose file tools*
The moose likes JSP and the fly likes Allow Only include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Allow Only include" Watch "Allow Only include" New topic
Author

Allow Only include

Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Hi,

I have a servlet (content.java) which acts as main page. I have a JSP file (footer.jsp) which acts as footer in that page. I am including the JSP in the server using RequestDispatcher include. It works perfectly fine. if I click the url http://localhost/servlet/content

But I don't want users to be able to do this:

http://localhost/jsp/footer.jsp

So actually I want the configuration which allows jsp to be inlcuded Only and not requested or forwarded.

Thanks.

Vikas
[ January 19, 2007: Message edited by: Bear Bibeault ]

Vikas Aggarwal

Founder @
Leads and Deals Limited

www.LeadsAndDeals.com
Mukesh Mittal
Ranch Hand

Joined: Jan 13, 2006
Posts: 31
You can store jsp in web-inf folder.
Stewart Johnson
Greenhorn

Joined: Dec 11, 2006
Posts: 5
Use cutom tag for footer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Originally posted by Stewart Johnson:
Use cutom tag for footer


Which, especially if you are using JSP 2.0 which supports tag files, is incredibly easy to do and much preferable to includes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Thanks a lot for your answers. I guess I can not go for custom tags because I am including JSP inside a SERVLET. Is there any other option than storing jsp inside web-inf dir?

Thanks.

Vikas
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Originally posted by Vikas Aggarwal:
I guess I can not go for custom tags because I am including JSP inside a SERVLET.


Huh?

I have no idea what you mean by that.
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Hi,

I meant that I can not use the tags inside a servlet. So using custom tag is not an option. I will have to use dispatcher. Is there any other way to do this and protect the footer.jsp?

Thanks,
Vikas
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

So you are generating the main page with a servlet and including JSPs for the footer? That's an odd thing to do. Why not use a JSP for the main page as well?

But back to the original issue, placing the footer.jsp under the WEB-INF hierarchy will prevent direct addressing.
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Thanks. Actually my company has acquired an application which has servlets as main content pages and we are given task to customise it. So we are using JSPs as footer and header. The main content pages can not be changed to JSPs now.

Thanks. I will keep my JSPs inside web-inf.

Vikas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Allow Only include