Or maybe a quicker alternative to the ones suggested by Arnauld would be to
use the 'include' directive. Though the suggestion 1 suggested by Arnauld is
the desired design pattern to be followed, using include would be faster to
incorporate in the existing jsp pages.

Just write in the validation in a separate jsp and include the jsp at the
begining of the pages. Remember to use only the implicit objects in the
included page ie. session, request etc.



-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 06, 2001 1:11 AM
To: [EMAIL PROTECTED]
Subject: Re: Call method in each page


Arnauld,
A few suggestions:
1) Redesign your architecture to use a Front Controller pattern (Core J2EE
Patterns pg 74)  The idea behind this is to move the duplicated code from
your multiple JSP pages and put it into a controller class. This class
would be one or more servlets that would handle the initial requests.  The
authentication logic would be put inside the servlet which would
authenticate the user and dispatch the request to the next view (JSP
page).  If the user did not have the right credentials, then they would be
directed to another JSP page which handles invalid authorizations.  You
could also have the servlet call helper classes that do the validation
instead of having the code directly inside the servlet.  A 'Mediating JSP'
implementing the 'JSP Front Strategy' could also be used in place of the
servlet. This solution is less desirable than a servlet controller.

2) A less desirable solution is to create a different superclass that the
JSP then extends.  The additional authentication logic would then be put in
the superclass.  To have a JSP extend a class other than the default one
used by the JSP engine, you would use the <%@ page extends="..." %>
directive.  This solution is dangerous in that you need to understand what
the default classes do.

-Richard

At 11:45 AM 9/5/01 +0200, you wrote:
>Hi all,
>i want to call a method on each jsp page ( typically, i want to test the
>right access of my user ).
>But i have a lot of page, and i don't want to add the method call on all
>page.
>I can use the "extend" procedure ( create my super class of jsp ), but it
is
>not advised.
>So, how can i do this .
>Thank you all
>
>Arnauld Lemaire
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to