Michael Wentzel wrote:
> > As a part of authentication check, I am checking for a session
> > attribute to validate user login across pages.
> > eg:
> >
> > if (session.getAttr("user")==null){
> > sendRedirect(loginpage);
> > }
> >
> > But now, I am keeping these lines in all my jsp files(cut and
> > paste)..If I
> > have to change somethg with that I need to change in all jsp pages..
> >
> > Is there any better way than this?? like keeping session
> > -checking code in
> > seperate file and including in all pages??
>
> Yes, you can put all your common code in a separate file, say common.jsp,
> and then include the following on all your pages:
>
> <%@ include file="common.jsp" %>
>
> You can also have multiple @include tags on a single page so you could
> split up a file if need be.
>
Another possibility is to create a simple custom tag that does the check for
you. The example application in the Struts Framework project
<http://jakarta.apache.org/struts> includes just such a tag. It is invoked like
this:
<app:checkLogin/>
and currently performs logic very similar to your code snippet.
>
> ---
> Michael Wentzel
Craig McClanahan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]