ok .. lemme try,


---------------------------------------[ login.html ]--------
<HTML>
<head>
        <title>Login</title>
</head>
<body>
        <form method=post action="login.jsp">
                Login <input type=text name=login><br>
                Password <input type=text name=password><br>
                <input type=submit>
        </form>
</body>
</HTML>

---------------------------------------[ login.jsp ]--------
<%
        String strLoginNam = request.getParameter("login");
        String strPassword = request.getParameter("password");

        //assuming they are not null
        if(  strLoginName.equals("admin") && strPassword == "nimda" ) {
                session.setAttribute("currUserName", strLoginName );
%>
        <jsp:include page="homepage.html" />
<%
        }
        else {
%>
        <h2>Sorry Invalid Login/Password !!</h2>
        Use the browsers <a href="login.html">BACK</a> button and try again !
<%
        }
%>

-------------------------------------[ showprofile.jsp ]--------

<HTML>
<%
        if( session.getAttribute("currUserName") == null ) {
%>
        <H2>Error</H2>
        You will need to <a href="login.html">Login</a> first !
<%
        }
        else {
%>
        <%@include file="userprofile.jsp" %>
<%
        }
%>
</HTML>

-------------------------------------[ logout.jsp ]-------------
<%
        session.removeAttribute("currUserName");
        response.redirect("index.html");
%>

---------------------------------------------------------------------

This is just a small off-the-top-of-my-head example. I am sure there can be
better once. I hope this helps :)


Mayuresh

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Richie Bab A. Boyboy
Sent: Wednesday, May 23, 2001 5:07 PM
To: [EMAIL PROTECTED]
Subject: JSP


Hi people!
Could anyone send me a jsp code using session object?
I have a problem using the session.setAttribute() method.

===========================================================================
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