Hi Declan
            if possible can u plz send me those XSL pages also
it will very helpful to me. 
thanks
rammi

-----Original Message-----
From: declan kelly [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 06, 2001 8:26 PM
To: [EMAIL PROTECTED]
Subject: Re: Cocoon and Sessions 


I bet your error is caused by not including the create
session directive in the namespaces declaration.

Anyway here's a very simple little login thingy, it
takes stuff from a form and logs you in or redirects
you back.

<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="login-html.xsl"
type="text/xsl"?>
<?xml-stylesheet href="login-wml.xsl" type="text/xsl"
media="wap"?>
<?xml-stylesheet href="page-chtml.xsl" type="text/xsl"
media="imode"?>
<xsp:page language="java"
xmlns:esql="http://apache.org/cocoon/SQL/v2";
xmlns:xsp="http://www.apache.org/1999/XSP/Core";
xmlns:session="http://www.apache.org/1999/XSP/Session";
create-session="true">
        <xsp:logic>
                String sqlstring = "";
                String username ="";
                String passwd = "";
                String UID="";
                final static char APOS = (char)39;
                final static char BLANK = (char)32;             
        </xsp:logic>
        <page>
                <xsp:logic>                     
                        username = request.getParameter("username");
                        passwd    = request.getParameter("passwd");
                        
                        (username.replace(APOS,BLANK)).trim();
                        (passwd.replace(APOS,BLANK)).trim();
                        
                        <!--Get rid of case sensitivity-->
                        username.toLowerCase();
                        passwd.toLowerCase();
                        
                        sqlstring = "SELECT * FROM users WHERE user_name =
'" + username + "'";
                </xsp:logic>
                <esql:connection>
                        <esql:pool>project</esql:pool>
                        <esql:execute-query>
                                <esql:query>
                                        <xsp:expr>sqlstring</xsp:expr>
                                </esql:query>
                                <esql:results>
                                        <esql:row-results>
                                                <xsp:logic>
                                        if(passwd.equals(<esql:get-string
column="passwd"/>))
                                                {
                                                        <!--Set the session
variable UID to the users
UID and jump to their page-->
        
<session:set-attribute name="UID">
        
<esql:get-string column="uid"/>
        
</session:set-attribute>
                                                
                                                
response.sendRedirect(response.encodeRedirectURL("menupage.xml"));
                                                }
                                        else
        
response.sendRedirect("login.xml?error=1");     
                                </xsp:logic>
                                        </esql:row-results>
                                </esql:results>
                                <esql:no-results>
                                
<xsp:logic>response.sendRedirect("login.xml?error=1");</xsp:logic>
                                </esql:no-results>
                        </esql:execute-query>
                </esql:connection>
                <link href="login.xml">Try Again</link>
        </page>
</xsp:page>


Then on every page which you should be logged in to
see include this 


<!--#####################################-->
<!--Check if User has logged in-->
        try{<session:get-attribute name="UID"/>;}
        catch (NullPointerException e)
           {
                response.sendRedirect("login.xml");
           }
<!--#####################################-->




--- Truhann van der Poel
<[EMAIL PROTECTED]> wrote:
> I am new to Cocoon and sessions. Are using C1.8.2.
> 
> Can anybody send a beginner sample (or pointer to
> help-documentation) to
> setup/save/retrieve variables from a session.  
> All the <session:xxx> tags in my xsp page create
> NullPointer's.
> 
> Truhann
> 
>
---------------------------------------------------------------------
> Please check that your question has not already been
> answered in the
> FAQ before posting.
> <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail:
> <[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <[EMAIL PROTECTED]>
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>
*******************Confidential Notice********************

This e-mail communication may contain information that is
confidential and privileged. The information is intended
to be for the use of the addressee only. If you are not the
named addressee you should not disseminate, distribute or
copy this e-mail: to do so could be a breach of confidence.

Kshema Technologies Ltd.,
# 33/1, Lalbagh Road, Bangalore 560027, INDIA. 
Tel: (91) 80- 2995114/5/6
Fax: (91) 80 2272933 

**********************************************************

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to