• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Allow Only include

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can store jsp in web-inf folder.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use cutom tag for footer
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
We don't have time to be charming! Quick, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic