• Post Reply Bookmark Topic Watch Topic
  • New Topic

NO-Cache for 1000 JSP pages

 
james billa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I know to avoid JSP page from being cached we need to use code below. But if I have 1000 pages, instead of writing this code at each page, can i do it globally at one place? if so how to do it? Thanks.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet filter.

You should never put Java code of any kind into a JSP page.
 
Anurag Blore
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

I agree we should not put java code in the JSP but some time while working practically we will have lot of requirement which can be achieved easily using scriptlet.

For example doing some total of records or providing a href link from one column of each row displayed.

What is your thought about this?

Thanks,
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java code belongs in Java classes.
To control requests and do some business logic, use a Servlet class.
To transfer data, use a Javabean class.
To interact with databases, use a DAO class.
To do some utility stuff, use an Utility class, if necessary wrapped by custom EL functions.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
someties depending upon the jsp page we need to cache /Uncache . But the concept of using filter applies to all .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never had an occasion to not set the no-cache headers on a JSP page. But if that's the case, the "if" statement works just fine in filters.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RaviNada Kiran wrote:someties depending upon the jsp page we need to cache /Uncache . But the concept of using filter applies to all .
You can also just let the url-pattern of the Filter cover the desired pages. Don't think it the hard way, dude.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice Bauke.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!